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

  1. alexguzun
    Posted 3 years 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


    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
    Plugin Author

    Posted 3 years ago #


    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.

  3. alexguzun
    Posted 3 years ago #

    Dakujem pekne
    Let me try it then


  4. sopedro
    Posted 3 years 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:

    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,


  5. sopedro
    Posted 3 years ago #

    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)))))


  6. jazzigor
    Plugin Author

    Posted 3 years 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
    	IF condition_2 THEN
    		RETURN value_if_condition_2_met
    		IF condition_3 THEN
    			RETURN value_if_condition_3_met
    			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
    Posted 3 years ago #

    Thanks Igor...

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

    Thank you

  8. jazzigor
    Plugin Author

    Posted 3 years 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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Jazzy Forms
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic