• Resolved Graicifyd

    (@graicifyd)


    Hi,

    Thank you for your support always.

    I have a created a slider with range number 1 – 1,000,000.

    I want a result where a particular range will be multiplied by a number I defined. For instance if 1 – 10, 000 is selected, the result will be (1-10,000)* 2 and if (10001 – 50,000) is selected the result will be (1-10,000)*2 + (10001 – 50,000)*3

    So I created this formula

    IF( fieldname1<10000, fieldname1*2,fieldname1>10000, fieldname1*3 )

    It works for the first part of <10000 but once it gets above 10000it returns ‘true’ as the answer. Please can you help me with it.

    I still want to create more rules for milestones like 100, 000, 500, 000 etc.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @graicifyd

    You cannot pas more than three parameters to the “IF” operation,
    because the structure of the “IF” operation is:

    IF(condition, result if condition true, resut if condition false)

    Put you can nesting multiple “IF” operations.

    The following equation is hypothetical because you don’t have described the operations in case fieldname1 be over 50000:

    
    IF(fieldname1<10000, fieldname1*2,IF(fieldname1<50000, 10000*2 + (fieldname1-10000)*3,  10000*2 + 50000*3 + (fieldname1-50000)*3))
    

    However, in cases similar to yours would be easier to understand, using function structure with “if” conditional statements instead “IF” operations:

    
    (function(){
    if(fieldname1<10000) return fieldname1*2;
    if(fieldname1<50000) return 10000*2 + (fieldname1-10000)*3;
    return  10000*2 + 50000*3 + (fieldname1-50000)*3;
    })()
    

    Best regards.

    Thread Starter Graicifyd

    (@graicifyd)

    Thank you for your respnse, it was really helpful. How do I write a statement saying ‘If fieldname1 is less than 50, 000 and greater than 10, 000?

    I tried his IF(fieldname1<50000,>10000) it didn’t work.

    Plugin Author codepeople

    (@codepeople)

    Hello @graicifyd

    Please read the structure of the IF operation, I described it in the previous entry, you are using it with a wrong structure again.

    If you want to check for a value into a range, you should to compare with both corners but using the AND operation or the and operator &&

    
    AND(10000<fieldname1, fieldname1<50000)
    

    or

    
    10000<fieldname1 && fieldname1<50000
    

    Best regards.

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

The topic ‘Variable Result from a Slider’ is closed to new replies.