• Resolved blue

    (@life2)


    Hi, I’m having trouble with fixing the equation (below) of the calculated field as it doesn’t seem to work. Can you help me with this?

    (function(){
           if(fieldname14)
       {
            if(and(fieldname14 >= "1", fieldname14 <= "3")) return '1';
             if(and(fieldname14 >= "4", fieldname14 <= "6")) return '2';
            if(and(fieldname14 >= "7", fieldname14 <= "9")) return '3';
        }
        return ' ';
    })()
    • This topic was modified 5 years ago by blue.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @life2

    Javascript is a case sensitive programming language where the uppercase and lowercase texts matter. Furthermore, the number should not be enclosed between single or double-quotes symbols. Your equation can be implemented as follows:

    (function(){
       if(fieldname14)
       {
            if(fieldname14 <= 3) return 1;
            if(fieldname14 <= 6) return 2;
            if(fieldname14 <= 9) return 3;
        }
        return '';
    })()

    or using mathematics:

    IF(fieldname14, CEIL(fieldname14/3), '')

    Best regards.

    Thread Starter blue

    (@life2)

    Okay, so I can’t use “and” inside the if statement?

    Plugin Author codepeople

    (@codepeople)

    Hello @life2

    You can use the “AND” operation if you want, but in this case, it is unnecessary. You can implement the equation as follows, even if the use of the “AND” operation is redundant:

    (function(){
       if(fieldname14)
       {
            if(fieldname14 <= 3) return 1;
            if(AND(3< fieldname14, fieldname14 <= 6)) return 2;
            if(AND(6< fieldname14, fieldname14 <= 9)) return 3;
        }
        return '';
    })()

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Issue with equation for calculated field’ is closed to new replies.