# Formulas

This feature is included in the Enterprise and ReportR plan.

A great new feature that allows you create your own **formula** using items from your questionnaire. You can use the /*-+() to create formulas using variables such as answers or quiz scores to calculate an average, for example.

Can't wait to create your formula? Make sure your questionnaire is completed then head straight to the **Extra Options **tab and select **Formulas**.

Click **Create formula** and you're on your way! Let's see how to build the formula.

**Title**- name your formula. Make it something that will be clear to you if you want to come back to edit it.**Variable**- you cannot edit the variable but you can copy it to use in outcomes, email templates or results.**The formula**- build you formula here. Use the circled symbols to put your formula together. Click**Variables**to access the drop-down menu of questionnaire variables that you can use in your formula. For example, you could write:*|q1_response|**(*|q2_response|*-*|q3_response|*)

One formula isn't enough for you? Click **Create formula** to add as many new formulas as you like.

If you're on the ReportR plan, you'll have an extra option to include **Serverside** calculations.

**Serverside variables** or Benchmark variables make the calculations taking data from the server, often averages. This allows you to show data in the PDF report for the entire population or from all responses received rather than from just one response.

They will add the following variables for each Formula:

The **average result**, the **average result by personal ID** which creates an average when one individual performs the test or assessment multiple times, and the **sum result by personal ID**, which returns the sum of all scores for all responses with the same personal ID.

Want to add a more advanced formula? Here's how you can use different variables in your formula:

**{QB1_CUSTOM_SCORE} -**the question block custom score value that was obtained. It is valid for the respondent who’s taking the questionnaire and will add the custom scores of each answer in one question block. You can use this variable in your formula or also as a piping variable**{QB1_CUSTOM_SCORE_PERCENTAGE} -**the question block custom score value as percentage. It's the same as the variable just discussed**{QB1_CUSTOM_SCORE}**but will calculate as a percentage.**{QB1_CUSTOM_MAX_SCORE} -**the maximum total score for one question block.**{Q1_CUSTOM_SCORE}**- the custom score value for this specific question.**{Q1_CUSTOM_SCORE_PERCENTAGE}**- this is the same as above**{Q1_CUSTOM_SCORE}**but then calculated as a percentage.**{CUSTOM_SCORE}**- the value of all custom scores for all questions (or for all question blocks) together.**{CUSTOM_SCORE_PERCENTAGE}**- the value of the custom score as a percentage compared to the max score.**{CUSTOM_MAX_SCORE}**- the maximum score for the whole questionnaire.

For advanced users we recommend

, a built-in object that has properties and methods for mathematical constants and functions. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math**Math**

## How can your formula be used?

You can create an outcome that will be displayed based on the value of the formula, or send an email after survey completion, depending on the result of the formula. Formulas will also help you in displaying scores as percentages on the final screen.

### Outcome based on formula

Watch this video to learn how to use formulas to show the correct outcome, or follow the steps below.

After you have created your formulas as described above, click on the **Outcomes** feature in **Extra options**. See the Outcomes guide for full details about setting up your Outcome screen. We'll just look at the final part, which is where the **Formula** function comes in. You'll need to select Show this outcome **when a certain condition is met**. From the drop-down menu, click **Formula**.

Now use the drop-down menus that will come up to choose which formula you want to use, how it should be used and what the values should be.

Click **Apply** and your Outcome is now set to be shown with the right formula value.

### Email template based on formula

Once you have saved your formula, click on the **Email template****s** feature in **Extra options**. See the email template guide for full details about setting up your email templates. When you need to specify when to send the email, this is where the **Formula** function comes in. Just click on the arrow and select **Formula**.

Now you can choose which formula you want to be used and for which values you want the email to be sent out. Click **Apply **and you're all set.

### Formulas to show scores in final screen

Formulas can also be used together with custom scores to create a final screen where respondents will see their scores as a percentage for each set of questions. This video here talks you through all the steps!

You can also use the variable **Formula ranking table** to easily insert a table with results of all formulas ordered from highest to lowest. The steps are similar to those shown in this video, with setting up custom scores and formulas.

That's all! Now log in and try out the formulas feature for yourself!