Within Dapresy Pro there are several ways of creating your own variables based on existing variables. This allows you to analyse, combine and build entirely new views of the data that can be used in your reporting. In this article we have a look at the different options available for creating new variables.

Compute variable is one of the more powerful tools within Dapresy Pro. It is used to create and build your own variables based on the data that exists in your project. You freely choose the number of options, variable type, and have a range of operands to choose from. You can also build computed variables based on data from already created computed variables.

Computed variables are treated just like any other variable from a dataset, which means they can be used in filters, charts, and tables with no limitation. Computed variables are formed as definitions of data, which means that these variables will update themselves whenever new data is imported or when the data that they are based on changes. This means you set the definition at the start, and you only need to adjust them if the actual definition changes. Otherwise your computed variables will stay updated all the time.

To create a new variable, click the “Create new variable” option in top left corner, in the resulting popup, select what type of variable to create, then continue to create the new variables.

*Here we see the option for selecting the type of variable to be created.*

To edit, or delete, an already created compute, index or merged variable use the edit and delete icons displayed in the most right column of the Question grid, see example of these icons in the image below.

*Here we see how the edit and delete icon appears for computed, merged and index variables. *

### Define Answers

First step in creating a new computed variable is to determine the meta data. This is done in the first tab *Define answers*. Here you give your new variable a unique code and a report text that will be the name of the variable. You have the option to choose between a number of different variable types for your new variable. The categorised types with answer alternatives and the ones without answers.

If the variable you like to create is of a type without answers, like for example an open ended text variable, you won’t have more meta data settings that you can or need to define.

If the variable you are about to create is a categorical variable you must determine how many answers it should consist of. Each answer alternative must have a name and you have a few optional settings for average calculation, negative/positive shares and colors.

* *

- Each computed variable need a unique code and a report text that will be the name of the variable.
- Select a variable type for your new variable.
- Set number of answers.
- Question color. Read more about question colors in chapter.
- Use a color template for your answers or set colors manually.
- Change sort order among the answers.
- All answers need a report text.
- Settings for mean categorical calculations. Settings for factor averages and excluding answers works the same as for imported variables.
- Apply negative, neutral or positive settings for negative/positive shares chart type.

### Define Calculations

This is where you select which existing variables should be included in your computed variable and how the calculations should be performed. The options available differ a bit depending on what variable type you are working with but the four main components are the same irrespective of type selected.

Variables | Here you select the variables to include in your calculations. |

Answers | Select one or several answers and click “Add to expression” to add them to your calculations. |

Operators & Functions | Use operators to combine different variables and answers. Add with “Apply Function” or write yourself in the expression. Click here for more information. |

Expression | This is where you can see all variables, answers, operators and functions used in your calculations. It is also possible to edit the expression here. |

Next steps:

- Use drop down to navigate between the answers in your computed variable.
- Select the variables to include in your calculations. You can also choose among your already created variables, and if you work in an older project the legacy external data.
- Select one or several answers and click “Add to expression” to add them to your calculations.
- Use operators to combine different variables and answers. Functions will help you to perform certain calculations. For example, function COUNTRESPONSE can be used to calculate the number of respondents.
- This is where you can see all variables, answers, operators and functions used in your calculations. It is also possible to edit the expression here.
- Validate your calculations to check that you get what you expect. If your expression is incorrect you will be notified.

If you have problems getting your expression correct, try to add one part at a time and use Validate to check where you get the errors. Parentheses are always useful to separate different parts of your expression.

Note: You will not be able to include variables of index type in your computed variables. That is because all calculations in computed variables are made on a respondent level while index variables can be used only on an aggregated level.

Some examples how to use the compute in combination with dates/periods can be found here.