• Resolved jesd00

    (@jesd00)


    Hi there – I spent the day yesterday browsing the forum and experimenting, but can’t seem to properly solve my need.

    I’m calculating the difference between two fields (that part works great), but then if the result is greater than zero I’d like to also display the word “INCREASE” otherwise display “DECREASE”

    Here’s my calculated field by itself:

    [calc][field current_observation_value]-[field prior_observation_value][/calc] (the result is 7.918)

    And here’s where I tried also do the compare:

    [set dif][calc][field current_observation_value]-[field prior_observation_value][/calc][/set]
    [get dif]
    <br>
    [pass field=dif]
    [if pass={dif} compare=more value=0]
    INCREASE
    [else]
    DECREASE
    [/if]
    [/pass]

    (I get the else result every time)

    Any help you could provide would be appreciated! Thanks!

    • This topic was modified 3 years, 9 months ago by jesd00.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Use [pass vars] instead of [pass field=dif] and {DIF} instead of {dif}.

    Does that change anything?

    Thread Starter jesd00

    (@jesd00)

    Hi Peter, thanks for the quick reply. Unfortunately that didn’t seem to make a difference.

    Here’s a screenshot if it’s helpful:

    screenshot

    What is the output of {DIF} outside the if statement?

    [pass field=dif]{DIF}[/pass]

    Thread Starter jesd00

    (@jesd00)

    With [pass field=dif]{DIF}[/pass] by itself, I just seem to get literal DIF with the curly brackets. The value should be 7.918.

    When I do a [get dif] the proper output is displayed.

    screenshot2

    Try:

    [pass vars]
    [if pass={DIF} compare=more value='0']

    Instead of :

    [pass field=dif]
    [if pass={dif} compare=more value=0]

    You do not have a field DIF – you have a variable. Also the ” for the value are important.

    • This reply was modified 3 years, 9 months ago by polarracing.
    • This reply was modified 3 years, 9 months ago by polarracing.
    • This reply was modified 3 years, 9 months ago by polarracing.
    Thread Starter jesd00

    (@jesd00)

    Hi polarracing – thanks for the suggestion. Didn’t seem to make a difference though.

    Screenshot:

    screenshot3

    Sorry, my mistake – wrong code: try this:

    [if var=dif not value=’0′]

    This should do the trick:

    [set dif][calc][field current_observation_value]-[field prior_observation_value][/calc][/set]
    [get dif]
    <br>
    [if var=dif value='0' compare=more and var_2=dif]
    INCREASE
    [else]
    DECREASE
    [/if]
    • This reply was modified 3 years, 9 months ago by polarracing.
    Thread Starter jesd00

    (@jesd00)

    That worked! Thanks so much to both of you for having a look at this! Much appreciated.

    you can also use
    [pass vars]
    [if var=dif compare=”>” value=’0′]
    Increase
    [else]
    Decrease
    [/pass]

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘IF/ELSE Compare, Is Calculated Field Greater than Zero…’ is closed to new replies.