# Matrix with calculated totals

 Compatibility: IdSurvey 6 IdSurvey 7 X √

With IdSurvey you can create matrixes and 3D matrixes with calculated cells to easily display totals (or any kind of calculation) for each row or column.

You can write any algebraic expression using integers, open-ended answers of other cells and contact fields.

If you use values of answers given on the same page, the fields will be displayed but the respondent will not be able to edit them. The calculations will update automatically every time that a given answer is edited.

Here we are going to show you two examples on how to set dynamic calculations on a standard matrix (calculating the total of the column) and on a 3D matrix (calculating the total of each row and each column).

## Example on a standard matrix ## Step 1

In order to set a matrix with the calculation of the total as in the example above, you will only need to create the matrix with all the rows. Each row will contain only one open-ended numeric answer.

## Step 2

Create the last row for the total.

Note

• To prevent that the arrows icon for increasing the number will be displayed, remember to set this answer option as an open-ended text answer.

## Step 3

Click on the settings menu of the answer option and add the algebraic expression on “Preset Value”, such as `[Q7.1]+[Q7.2]+[Q7.3]+[Q7.4]`. Each code in square brackets retrieves the answer written in the corresponding row, in this example the 4 rows of question Q7.

Note

• The value of the total will be automatically calculated each time you enter a cost in the previous row.
• The respondent will not be able to edit the total.
• Besides being displayed, the total will be saved as any answer of the interview and you will be able to use it for further display conditions or other rules of the questionnaire.
``````/page P4

Q7 ->T
For each term of 2018 write the costs incurred by your company for goods and services.

/rows
.1 1st term
.2 2nd term
.3 3rd term
.4 4th term
.5 Total
/cols
1  /V "Ni"
/cells
.5,1 /D "[Q7.1]+[Q7.2]+[Q7.3]+[Q7.4]" /V "S"``````

## Example on a 3D matrix ## Step 1

In order to set a 3D matrix with the calculation of the total of row and column as in the example above, you will just need to create the 3D matrix with all the rows and column needed. Each cell will have to include only one numeric open-ended answer.

## Step 2

Create the last row and the last column that will contain the corresponding totals.

Note

• If you intend to create a 3D matrix with totals per row or per column, you can just skip the creation and setting procedure of the cells that are not necessary.

## Step 3

To prevent that the arrows icon for increasing the number will be displayed, remember to set each answer option of the cells of the last row and last column as open-ended text answer. In order to edit this option click on the pencil icon of the cell to open the cell editing window, then click on the settings menu of the answer option.

## Step 4

Click on the pencil icon of the first cell of the last row, then on the settings menu of the answer option. Add the algebraic expression on “Preset Value”, such as `[Q5.1.1]+[Q5.2.1]`.

Note

• Each code in square brackets will retrive the answer written on the corresponding cell. Please note that to retrieve a specific cell of the 3D matrix you need to write the code including 3 elements: question code, row code and column code. For example: `[Q5.2.1]` is composed by Q5 (question code), .2 (second row code) and .1 (first column code).

## Step 5

Repeat Step 4 for each cell that will contain a total of row or column.

Notes

• Please pay attention to the codes of the cells that will need to be summed when writing algebraic expression. The codes represent the exact coordinates of a specific cell.
• The value of the totals will be automatically calculated each time you enter the costs on the cells of the matrix.
• The respondent will not be able to edit the total.
• Besides being displayed, the totals will be saved as any other answer of the interview and you will then be able to use it for further display conditions or other rules of the questionnaire.
``````/page P3

Q5
Please write your VAT turnover for each semester of 2017 and 2018.

/celltemplate 1
1  ->T /V "Ni"
/celltemplate 2
1  ->T /D "[Q5.2.1]+[Q5.2.2]"
/celltemplate 3
1  ->T /D "[Q5.1.1]+[Q5.1.2]"
/celltemplate 4
1  ->T /D "[Q5.1.1]-[Q5.2.1]"
/celltemplate 5
1  ->T /D "[Q5.1.2]-[Q5.2.2]"
/celltemplate 6
1  ->T /D "[Q5.1.3]-[Q5.2.3]"
/rows
.2 2017
.1 2018
.3 Gap
/cols
.1 First Semester
.2 Second Semester
.3 Total
/cells
.2,.3 /celltemplate 2
.1,.3 /celltemplate 3
.3,.1 /celltemplate 4
.3,.2 /celltemplate 5
.3,.3 /celltemplate 6``````