# WordPress.org

## Jazzy Forms How IF condition is working? (8 posts)

1. alexguzun
Member
Posted 1 year ago #

Great plugin, reall.
I cna't get IF condition working.

Example, how to make correct expression for: if 1st_value is more than 10 then result should be calculated as 1st_value*2nd_value

or

i have YES/NO radio button with 1/0 values

and how to make expression:
if YES then calculate as 3rd_value*4th_value

i tried my best but i cna't IF get working, whta to use instead of THEN?

Thank you

2. jazzigor
Member
Plugin Author

Posted 1 year ago #

Hi.

My apologies for not coming up with a reasonable documentation yet.

First of all: please don't use IDs that start with numbers, that will result in invalid formulas. Valid IDs would be "value_1st", "first" or "value1".

Now, about the IF function. You can expect Jazzy Form's functions to behave at least similar to those in popular spreadsheets programs. I.e.: IF(condition, value_if_condition_met, value_otherwise)

I'm not sure whether it were 2 separate examples or they belong together. Here is the joint expression, as two nested IFs:

In words: If value1 is greater than 10 then result is value1*value2, otherwise if the radio button is set to yes then the result is value3*value4, otherwise it's zero.

I hope this makes it a bit clearer.

3. alexguzun
Member
Posted 1 year ago #

Dakujem pekne
Let me try it then

Alex

4. sopedro
Member
Posted 1 year ago #

Hi jazzigor, Your plugin is very cool and usefull.

But, i have a litle issue here, i have a formula with 5 nested 'if' conditions, but the formula only calculate de first two conditions. Why?

The conditions are dependent os an output formula and a dropdown list

the formula:

Thank you,

Pedro

5. sopedro
Member
Posted 1 year ago #

sorry, i found the solution, the problem is the construction of the nested "if" conditions i made.

The correct one is:

:)

6. jazzigor
Member
Plugin Author

Posted 1 year ago #

Nested IFs seem to cause a certain degree of confusion. I'll try to clarify it here, but you can as well google for any spreadsheet tutorial on this topic.

``IF(condition_1, value_if_condition_1_met, IF(condition_2, value_if_condition_2_met, IF(condition_3, value_if_condition_3_met, value_otherwise)))``

It is evaluated like this BASIC pseudo-code:

``````IF condition_1 THEN
RETURN value_if_condition_1_met
ELSE
IF condition_2 THEN
RETURN value_if_condition_2_met
ELSE
IF condition_3 THEN
RETURN value_if_condition_3_met
ELSE
RETURN value_otherwise
END IF
END IF
END IF``````

It's commonly called nested, because it is an IF function within the "then" or "else" part of another IF. One inside another like Matryoshka dolls.

7. sopedro
Member
Posted 1 year ago #

Thanks Igor...

One more thing, how can i control the visibility of an element with a condition?

Thank you

8. jazzigor
Member
Plugin Author

Posted 1 year ago #

sopedro, hiding/showing elements based on conditions is not there yet (as . But it's definitely on my to-do list. I'm tracking it at https://github.com/l90r/jazzy-forms-dev/issues/15

This topic has been closed to new replies.