Compatibility: | IdSurvey 6 | IdSurvey 7 |

X | √ |

With IdSurvey you can add algebraic expressions in the body of questions and answers, in the preset value of an open-ended question, display conditions, update contact field, skip conditions and FlowScript.

Thanks to InPage Functions you can also use the data collected from questions of the same page where you use an algebraic expression. By doing so you can easily create matrixes with the total of row or column.

Note

- The ARITH function available on IdSurvey 6 and on the previous versions is not available anymore. By introducing IdSurvey 7 the procedure for algebraic expression was simplified and is now available for each function of the questionnaire (texts, conditions, update contact field, preset value, etc.).

Please find some examples of application below.

## Example 1 – Algebraic expression on the texts of the questionnaire

In order to add algebraic expressions to any text of the questionnaire (e.g. total of male and female employees) you have to click on the “dynamic text” icon in the text editor and write the expression that you need.

*Total*

`[Q1] + [Q2]`

The number written in the answer to question Q1 plus the number written on the answer to question Q2.

*Percentage (women on the total of employees)*

`100 * [Q2] / ( [Q1] + [Q2] )`

100 multiplied by the number written on the answer to question Q2, divided by the sum of the number written on the answer to questions Q1 and Q2.

Note

- The percentage will be calculated including decimal numbers. A workaround to only display integers is that of subtracting the calculated decimal number by repeating the expression adding 1%.

`( 100 * [Q2] / ( [Q1] + [Q2] ) ) - ( 100 * [Q2] / ( [Q1] + [Q2] ) ) %1`

## Example 2 – Algebraic expression on display conditions

Question Q2 will only be displayed if the number of employees is equal or less than 10. You only need to add a display condition using the algebraic sum to calculate the total number of employees written on question Q1.

`if([Q1.1]+[Q1.2]<=10 )`

It will be displayed if the number of male employees written in row 1 of question Q1 plus the number of female employees written in row 2 of question Q1 is equal or less than 10.

## Example 3 – Algebraic expression on preset value

The “Preset Value” feature allows you to pre-populate an open answer of the questionnaire.

Besides manually adding a preset value you can also add the value of a different open-ended answer, of a contact field to a value calculated with an algebraic expression.

In order to set a preset value of an open answer you have to click on the settings menu of the answer and write the expression on the “Preset value” box.

In this example we are asking how many recruitments the company made in the past 12 months. The answer will be pre-populated with the sum of the the employees both male and female, subtracting the total number of employees that the company had during the previous year.

Note

- Thanks to InPage Functions the feature “Preset Value” can also be used to pre-populate answers on the same page. Such feature allows you to add totals or other calculations to a matrix. In this case the answer containing the result of the expression cannot be edited by the respondent since it only calculates the answers given on the matrix. For a detailed guide please go to the article related.

## Example 4 – Algebraic expression on update contact field

The dynamic calculation can also be used to populate a contact field. In order to do that you have to click on the settings menu of the answer, enabling the “Update contact field” function, choosing a contact field and writing the algebraic expression.

## Example 5 – Algebraic expression on FlowScript

FlowScript accepts the algebraic expression in conditions and in the population of a variable (Custom Fields).

Here we use an algebraic sum in the condition to populate a contact field with a calculated percentage.

`if ( [Q1]+[Q2] > 10) {Field1} = 100 * [Q2] / ( [Q1] + [Q2] );`

If the sum of the number entered in the answer to question Q1 plus the number entered on the answer to question Q2 is higher than 10, Field 1 will be populated with the result of the expression (100 multiplied by the number written on the answer to question Q2, divided by the sum of the number written in the answer to questions Q1 and Q2).