• Resolved ooaliceoo

    (@alicexwarehouse)


    Hello,

    I need to use this kind of formula :

    if(fieldname1>0;((if(fieldname1>=60000;(fieldname1-60000)*0,01526+1675,79;if(fieldname1>=17000;(fieldname1-17000)*0,02034+801,17;if(fieldname1>=6500;(fieldname1-6500)*0,03051+480,81;fieldname1*0,07397)))));0)

    I don’t understand how I need to transform it to use it in the plugin… I am very noob to this…

    Any help ? thanks a lot !

    Cheers

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

    (@codepeople)

    Hello @alicexwarehouse

    There are some issues in your formula. In javascript the decimal symbol is the dot and not the comma.

    Furthermore, javascript is a case-sensitive language. You can use the “IF” operation distributed with the plugin, whose structure is: IF(condition, result if condition is true, result if condition is false). Or you can use the “if” conditional statement of javascript whose structure is different.

    So, the formula can be implemented as follows:

    
    IF(0 < fieldname1, IF(60000 <= fieldname1, (fieldname1 - 60000) * 0.01526 + 1675.79, IF(17000 <= fieldname1, (fieldname1 - 17000) * 0.02034 + 801.17, IF(6500 <= fieldname1, (fieldname1 - 6500) * 0.03051 + 480.81, fieldname1 * 0.07397))), 0)
    

    or you can implement it with function structure and “if” conditional statements as follows:

    
    (function(){
    	if(fieldname1<0) return 0;
    	if(fieldname1<6500) return fieldname1 * 0.07397;
    	if(fieldname1<17000) return (fieldname1 - 6500) * 0.03051 + 480.81;
    	if(fieldname1<60000) return (fieldname1 - 17000) * 0.02034 + 801.17;
    	return (fieldname1 - 60000) * 0.01526 + 1675.79;
    })()
    

    Best regards.

    Thread Starter ooaliceoo

    (@alicexwarehouse)

    thank you so much for your precious help.

    I have another question if I may : is it possible to round up the result to have only 2 numbers after the . as I am working with currencies ?

    If you want to see the fields

    Thanks again

    Plugin Author codepeople

    (@codepeople)

    Hello @alicexwarehouse

    Yes, of course. Please, use the PREC operation as the outermost operation in the equation. PREC(X,Y) rounds the number X with Y decimals.

    For example:

    
    PREC(IF(0 < fieldname1, IF(60000 <= fieldname1, (fieldname1 - 60000) * 0.01526 + 1675.79, IF(17000 <= fieldname1, (fieldname1 - 17000) * 0.02034 + 801.17, IF(6500 <= fieldname1, (fieldname1 - 6500) * 0.03051 + 480.81, fieldname1 * 0.07397))), 0), 2)
    

    or

    
    PREC((function(){
    	if(fieldname1<0) return 0;
    	if(fieldname1<6500) return fieldname1 * 0.07397;
    	if(fieldname1<17000) return (fieldname1 - 6500) * 0.03051 + 480.81;
    	if(fieldname1<60000) return (fieldname1 - 17000) * 0.02034 + 801.17;
    	return (fieldname1 - 60000) * 0.01526 + 1675.79;
    })(),2)
    

    Best regards.

    Thread Starter ooaliceoo

    (@alicexwarehouse)

    thank you very much for you quick answer.

    Best regards,

    Alice

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Need help for formula’ is closed to new replies.