• Resolved saketsays

    (@saketsays)


    Great plugin and am working on setting it up for my website. Had a quick question:

    I want to display a field as “Yes” or “No”, depending upon if a different calculated value is >= 0 or < 0( think we can use “IF”, however not sure how to implement).

    Can you please help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter saketsays

    (@saketsays)

    Think we can use something like below:

    (function(){
    if(fieldname4 >= 0) return “Yes”;
    if(fieldname4 < 0) return “No”;
    })();

    Thanks
    Saket…..

    Plugin Author codepeople

    (@codepeople)

    Hello,

    I’ll try to explain the process with an example. Assuming that the equation associated to the calculated field is: fieldname1+fieldname2, you simply should edit it as follows:

    IF(fieldname1+fieldname2<0, 'NO', 'Yes')

    Note: You cannot use the calculated field in its own equation, or you would be generating an infinite loop.

    Best regards.

    Hi,

    How do I put a name in place of the result?
    I’m creating a gasoline and alcohol fuel calculator where the gasoline value is YES and the alcohol value is NO. How can I do it?

    Thank you.

    Plugin Author codepeople

    (@codepeople)

    Hello @mdesigner86,

    Actually your ticket need some additional details, so, I’ll try to explain the process with a generic example.

    Assuming your current equation is the mathematical operation: fieldname1*fieldname2, and you want return as the equation’s result the texts:

    – Alcohol Methanol if the result is less than or equal to 10
    – Alcohol Ethanol if the result is greater than 10 and less than or equal to 100
    – Gasoline 85 Octanes if the result is greater than 100 and less than or equal to 200
    – Gasoline 92 Octanes if the result is greater than 200

    In this case the equation associated to the calculated field would be:

    (function(){
    var r = fieldname1*fieldname2;
    if(r <= 10) return 'Alcohol Methanol';
    if(10 < r && r <= 100) return 'Alcohol Ethanol';
    if(100 < r && r <= 200) return 'Gasoline 85 Octanes';
    else return 'Gasoline 92 Octanes';
    })()

    Best regards.

    I did it, thank you very much;)

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

The topic ‘Display text based on calculation’ is closed to new replies.