• Resolved victoriei101

    (@victoriei101)


    Hello,
    can you please help me with this equation?
    The calculation below is almost correct, except that I want to show value 60 when the calculated value is below 60.

    (function(){
    var v = fieldname2*((fieldname16 == 'Euro') ? fieldname23 : 1)*((fieldname17 == 'Fizica') ? .0015 : .005);
    
    if(v <= 10) return 0;
    if(v <= 60) return 60;
    return ROUND(v);
    })()

    Example:
    if fieldname2 value is 5000, and fieldname16 in NOT Euro, and fieldname17 is Fizica
    the calculation should be like 5000*0.0015=7,5

    and in this case I want to display 60.

    Basically 60 is minimum that should be displayed, except when the result of the calculation is above 60.
    Can you please tell me how to write this correct?
    Thanks

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

    (@codepeople)

    Hello @victoriei101

    In this case, the equation can be implemented as follows:

    
    MAX(60,ROUND(fieldname2*((fieldname16 == 'Euro') ? fieldname23 : 1)*((fieldname17 == 'Fizica') ? .0015 : .005)))
    

    Best regards.

    Thread Starter victoriei101

    (@victoriei101)

    The provided code displays 60 even when the user hasn’t gave any input value in fieldname2.
    Can I display 0 when fieldname2 is less than 10?
    Thank you for your fast reply

    Plugin Author codepeople

    (@codepeople)

    Hello @victoriei101

    In this case, edit the equation as follows:

    
    (function(){
    var v = fieldname2*((fieldname16 == 'Euro') ? fieldname23 : 1)*((fieldname17 == 'Fizica') ? .0015 : .005);
    
    if(v <= 10) return 0;
    return ROUND(MAX(60,v));
    })()
    

    Best regards.

    Thread Starter victoriei101

    (@victoriei101)

    It’s not showing 60 as minimun

    Here is the form backend
    https://ibb.co/4KYtRt8
    https://ibb.co/nDC7sQ0

    and here is the form live
    https://bit.ly/3mLzTwf

    fieldname12 is Taxa ANCPI intabulare

    Plugin Author codepeople

    (@codepeople)

    Hello @victoriei101

    The equation is correct, you should check your math. Replacing the values in the equation, it is:

    
    (function(){ 
    var v = (5000)*(("Lei" == 'Euro') ? (4.859) : 1)*(("Fizica" == 'Fizica') ? .0015 : .005);  
    if(v <= 10) return 0; 
    return ROUND(MAX(60,v)); 
    })()
    

    Evaluating the mathematical operations the value of v is 7.5, (it is less than 10). So, the equation’s result is 0.

    I’m sorry, but the support service does not cover the implementation of the users’ projects (forms or formulas) or debugging their equations. If you need that I implement your project, you should contact me through my private website: Custom Coding Service

    Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Minimum value’ is closed to new replies.