1. Home
  2. Other Resources
  3. Tips & Tricks
  4. Functions in Value Assignment

Functions in Value Assignment

There are several functions for value assignment. Each function can be used in multiple ways within value assignment and your survey’s functions. To understand how this works, firstly read the topic “Datatypes in Survalyzer“.

{{function.currentdateadd(days)}}

This function creates a date value and can only be stored in a date or text variable. (It’s most commonly used with a date variable). It can be used to employ a filter, connected to the current date a user fills out a survey. For days, positive and negative values are possible.

To get the current date, the function would look like this:

{{function.currentdateadd(0)}} 

Example Value: 05.08.2019

{{function.randbetween(a,b)}}

This function generates one random value for your value assignment. The value will be chosen between a and b. This function creates a number value, but can also be stored in a text and a real value.

To get a random number between 1 and 5 the function would look like this:

{{function.randbetween(1,5)}}

Example Value: 2

The random value will be generated for each respondent individually. For example, this function can be used to filter (or randomly show) one of five sections.

{{function.randbetweendistinctlist(a,b,c)}}

This function generates a distinctive list of random values. The values are chosen between a and b. The c defines the number of values to be generated. This function will not generate the same value twice within a list. The generated value can only be stored in a text variable, as all values in that list are separated by a comma.

To get a list of five values between 1 and 10, the function would look like this:

{{function.randbetweendistinctlist(1,10,5)}}  

Example Value: 2,4,3,9,6

This function can be used to show 5 out of 10 questions. Just use the filter technique of “contains” or “not contains”.

{{function.round({{varname}}, number_of_decimals)}}

This function will round a value to a defined number of decimals. This is useful, for example, to save a calculated value as a number without decimals (for example an average). This function usually rounds an existing variable value. The variable name is represented by {{varname}}. The number_of_decimals, as the name suggests, defines the number of decimals for the new rounded value.

To round a variable to a value with just one decimal, the function would look like this:

{{function.round({{calculated_value}}, 0)}} 

Example Value: 8.1

Depending on the number of decimals, the value can be assigned to a number datatype variable or a real datatype variable.

Updated on August 26, 2019

Was this article helpful?

Related Articles