Support » Plugin: Jazzy Forms » [Plugin: Jazzy Forms] How IF condition is working?

  • 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

    http://wordpress.org/extend/plugins/jazzy-forms/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author jazzigor

    (@jazzigor)

    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:

    IF(value1>10, value1*value2, IF(radio=1, value3*value4, 0))

    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.

    Dakujem pekne
    Let me try it then

    Alex

    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:

    IF(actividade=1, result_tmb*1.2, IF(actividade=2, result_tmb*1.375), IF(actividade=3, result_tmb*1.55), IF(actividade=4, result_tmb*1.725), IF(actividade=5, result_tmb*1.9))

    Thank you,

    Pedro

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

    The correct one is:

    IF(actividade=1, result_tmb*1.2, IF(actividade=2, result_tmb*1.375, IF(actividade=3, result_tmb*1.55, IF(actividade=4, result_tmb*1.725, IF(actividade=5, result_tmb*1.9)))))

    🙂

    Plugin Author jazzigor

    (@jazzigor)

    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.

    Thanks Igor…

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

    Thank you

    Plugin Author jazzigor

    (@jazzigor)

    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

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Jazzy Forms] How IF condition is working?’ is closed to new replies.