If, Then, Else logic is used when the answer of a specific question can change depending on the answer of a different question. For example, if a form had a tax rate question which varied by state, the user would have to create multiple tax rates fields with relevance in order to have the value change when a new state was selected.
If, Then, Else parameters
- If condition: If conditions are how the user specifies what the answer will be as well as what other question in the form is the condition. In the example above the tax rate question would have a condition such as IF (Question in form) EQUALS (Potential answer of question in form) THEN the answer to this question is (X) . So for this example the (Question in form) could point to a "State" question in my form. The (Potential answer of question in form) could be "New Jerseys" and (X) could be .07 which is New Jersey's State tax. So if the answer to State was New Jersey in my form the field for Tax Rate would automatically change to .07 without the user needing to type it.
- Else If condition: Else IF's are simply additional IF Statements. In my example above I could add an ELSE IF for: IF (State EQUALS New York THEN the answer to this question is .09 . So now the initial IF statement covers if New Jersey was selected but now there is an additional IF (or else if) for if New York is selected. The user can keep adding Else IFs to account for each potential answer.
- Else condition: Else is the answer that is displayed if none of your IF conditions are met. Again, in the example above if neither New Jersey or New York were selected my else condition would contain the answer displayed since neither of these answers were chosen.
Conditions
- Equal
- Not equal
- Less than
- Less than or equal
- Greater than
- Greater than or equal
- Is empty
- Is not empty
- Starts with - If the answer in a specified field starts with the desired value then the field will be set based on this condition being met.
- Contains - If the answer in a specified field contains the desired value then the field will be set based on this condition being met.
- Length is - If the answer in a specified field is equal to the specified length or number of digits then the field will be set based on this condition being met.
When to use If, Then, Else logic
- When the answer of a question is reliant on the answer of another question
- When you want the answer of a question to change when different options are selected or entered.
- When you don't want to add multiple relevance conditions for 1 question.
Examples
The example below shows a Tax Decimal Amount question that is pointing to a choose one question for State. Depending on the answer to the choose one question State, the answer to Tax Decimal Amt will change.
In the first screenshot, when NJ is selected the answer changes to .07.
In the second screenshot below you can see when NY is selected the answer changes from .07 which was NJ's answer to .09.
In the third screenshot below you can see when CA is selected the answer changes from .09 which was NY's answer to .05.
This examples settings would look like the screenshot below:
This example above shows the Tax Decimal Amount question have 3 IF conditions but no ELSE. In the below example the user added one more option for "other". The user also set an ELSE statement which says if the answer is not NJ, NY, or CA, then the answer is .02:
As you can see above no answer was selected therefore the answer to the Tax Decimal Amount is .02. This answer would remain the same if the user selected "other" as well since the ELSE statement covers all answers that are not NJ, NY, or CA.
The ELSE settings for the example above would look like the screenshot below:
If, Then, Else is not specific to a choose one tool. Users can set If, Then, Else conditions on fields such as numeric, text, select multiple, etc.. This setting is a great way to reduce the number of fields that are using relevance in your forms as well as make the building of forms quicker and easier.