Mathematical and Logic Functions
Logic
Function And()
Compares multiple values and returns true if all values are true or false if at least one input is false.
Syntax
And( e [, e…])
Parameter | Description |
---|---|
e1, e… | An expression or value, including functions, equations and question references to be evaluated to true or false. |
Function IIf()
Evaluates a true / false expression, and returns a parameter value if the expression is true and another if the expression is false.
Syntax
IIf( e, t, f )
Parameter | Description |
---|---|
e | An expression or value to be evaluated to true or false. |
t | Defines what to return if the evaluation of expression e is true. |
f | Defines what to return if the evaluation of expression e is false. Example: |
Function IsTrue()
The isTrue() function evaluates determines if an expression is true or false, Returns 1 if true otherwise 0 if false.
This function can be used to convert string based True/False results into a numeric representation.
By default, this function will interpret the following as True: 1, T, True, Y, Yes
This function is not case sensitive, so the value ‘t’ and ‘T’ both evaluate to True. In addition to the built-in interpretation of True, this function can optionally be passed a second parameter to define an alternative value for True. Used in this way this function is similar to the IsEqual function.
Syntax
IsTrue( e [, c] )
Parameters | Description |
---|---|
e | Expression to be evaluated as True. |
c | (Optional) Value to be used as a definition of True. Note that if a second parameter is provided, the built-in definitions of True no longer apply and only the value passed in will be tested. |
Function NotContains()
NotContains() determines whether none of the values retrieved from a repeating section, page or data source matches a specified value. Note that the value must be an exact match, although it is not case sensitive. This is the opposite of the Contains() function.
Returns 1 if no values match or 0 if any values match.
This is an aggregate function
Syntax
NotContains( v, r1 [, r…])
Parameters | Contains |
---|---|
v | The value to search for. |
r1 | Reference to a question within a repeating page, repeating section or multiple row data source. |
r… | (Optional) Additional references to extend the data set being matched. |
Function Or()
Compares multiple values. Returns true if at least one of them is true.
Syntax
Or(e1 [, e…])
Parameter | Description |
---|---|
e1, e... | An expression or value, including functions, equations and question references to be evaluated to true or false. |
Function StringContains()
Syntax
StringContains(paramtr1,paramtr2)
The function checks whether or not the second parameter paramtr2 is present in string paramtr1.
Function GreaterThan, LessThan, EqualTo
This group of functions compare their parameters. A true result of 1 or a false result of 0 is returned. These functions are often used in conjunction with the IIf function to return a string or value other than 0 or 1.
Syntax
IsEqual( p[1], p[2], .., p[n] )
IsNotEqual( p[1], p[2])
IsGreaterThan( p[1], p[2])
IsLessThanOrEqualTo ( p[1], p[2])
Parameter | Description |
---|---|
p[n] | Each parameter is an expression that is evaluated and then compared to the other parameter to determine a true or false value. |
Nested iif() formulas
Often, it is necessary to nest iif() functions to cater to scenarios where there are several possible input values.
For example, in the formula below, the [q1] reference has three possible values namely 1, 2,and 3 and resolves to the phrase Plane, Train, or Automobile.
Syntax
iif(isequal([q1],1),"Plane",iif(isequal([q1],2),"Train", "Automobile"))
Function Contains()
Contains() determines if at least one of the values retrieved from a repeating section, page or data source matches a specified value. Note that the value must be an exact match, although it is not case sensitive.
Returns 1 if any values match or 0 if no values match.
This is an aggregate function
Syntax
Contains( p1, p2[, p3…])
Parameters | Description |
---|---|
p1 | The value to search for. |
p2 | Reference to a question within a repeating page, repeating section or multiple row data source. |
[p3 …] | _(Optional) _Additional references to extend the data set being matched. |
Mathematical
Mathematical Operators
Operator | Description |
---|---|
+ | Addition operator. Can be used in any formula eg:Concat(3+2) would result in 5 being output. |
- | Subtraction operator. Can be used in any formula eg:Concat(3-2) would result in 1 being output. |
* | Multiplication operator. Can be used in any formula eg:Concat(3*2) would result in 6 being output. |
/ | Multiplication operator. Can be used in any formula eg:Concat(3*2) would result in 6 being output. |
^ | Power operator. Can be used in any formula eg:Concat(3^2) would result in 9 (3 to the power of 2) being output. |
% | Modulus operator. Can be used in any formula eg:Concat(10%3) would result in 1 (the remainder of 10 divided by 3 is 1) being output. |
Function Abs()
Returns a positive (absolute) version of the number passed in as a parameter.
Syntax
Parameter | Description |
---|---|
n | The number to be converted to absolute. |
Function Average()
Returns the average of a series of numbers.
This is an aggregate function
Syntax
Average( r )
Parameters | Description |
---|---|
r | Reference to a question in a repeating page, repeating section or multiple row data source. |
Function Round(), Ceiling() and Floor()
Returns the value passed into the first parameter, rounded to the number of decimal places defined by the second parameter, or to a whole number if the second parameter is not provided.
- Round – rounds to the closest given number of decimal places. For example, 0.1 becomes 0 while 0.9 becomes 1.
- Ceiling – rounds UP to the nearest given number of decimals. For example, 0.1 becomes 1 while 0.9 becomes 1.
- Floor – rounds DOWN to the nearest given number of decimals. For example, 0.1 becomes 0 while 0.9 becomes 0.
Syntax
Round( e , n )
Ceiling( e , n )
Floor( e , n )
Parameters | Description |
---|---|
e | An expression or value to be rounded, which may include equations, question references and function calls. |
n | (Optional) The number of decimal places to which the number will be rounded. Left out, 0 is the default and the value will be rounded to a whole number. |
Function Max() and Min()
Functions returns the highest and lowest number in a data set.
This is an aggregate function
Syntax
Max( r )
Min( r )
Parameters | Description |
---|---|
r | eference to a question in a repeating page, repeating section or multiple row data source. |
Function Sum()
The Sum() function returns the total of all numerical values in a data set.
This is an aggregate function
Syntax
Sum( r )
Parameter | Description |
---|---|
r | Reference to a question in a repeating page, repeating section or multiple row data source. |
Updated 4 months ago