Day 18: Calculation IF ELSE Logic
Previous Topic  Next Topic 

In the last lesson we asked you to give MENU question answers a score that can later be summoned in calculations. If you have not done that, go back and do it now before continuing with this lesson.

This lesson will show you how to use IF ELSE logic in the CALCULATION question to generate more complex messages.


Now do the following.

    1. Open the survey you created on Day 17 of this tutorial 'Day 17'. Create a copy of the survey under a different name. Name the survey 'Day 18'.

    1. In yesterday’s lesson you set up created menu scores for certain questions so that you were displayed a brief health analysis at the end of the survey. Today’s lesson will take this one step further by suggesting methods of improving your health depending on your question answers. Select the question, OVERALL in the main section. Add a CALCULATION question with the question prompt “Drinking”. Add the following expression to the question:

IF ({{M1}} > 2) "you drink too much."


This means that if the menu score for M1 is greater than 2, display the message “you drink too much”, otherwise show no message. INSERT the question so that it appears right after the question TOTAL in the main section.

    1. Add a similar calculation question with the question prompt “Smoking”. Make sure that the following expression is included:

IF ({{M2}} > 2) "You smoke a damaging amount of cigarettes."


    1. Create a calculation question and name it “Food”.  Add an expression so that a score greater than 3 will display the message, "You consume an excessive amount of junk food."

    1. Add a final calculation question with the prompt, “Exercise” and give it the following expression:

IF ({{M4}} = 5) "Do some regular exercise"

ELSE "Keep up a frequent exercise regime"

This means if the menu score collected for M4 is equal to 5, the message “Do some regular exercise” will be displayed. Otherwise we will see “Keep up a frequent exercise regime”.

    1. Now you can amend the MESSAGE question at end of your survey to display a more useful and intelligent message. Add a new sentence to the existing message that displays the answer to each of the questions you have created in today’s lesson. Make sure to leave a space between each variable so that the message is better presented. The text to display should now look like this:

You got a score of {{Total}}. This means {{Overall}}. {{Drinking}} {{Smoking}} {{Food}} {{Exercise}}

    1. Save your survey and run it a number of times so you can see how the final message varies depending on how you completed your survey.

The next lesson will show you how to use variables in the question prompt, displaying question answers in later questions as you progress through the survey.

Final Tip

HandHeld Systems Ltd ©