Number and currency expressions
Number and currency expressions are similar. However, many functions, methods, and operators may not work when evaluating numbers and currencies together.
If you use multiple currency fields, make sure they are the same type. Rating and slider fields can be used as number fields in expressions.
Example fields
We’ll use these sample fields in the expressions below.
FieldID | Type | Value |
num1 | Number | 10 |
num2 | Number | 22.45 |
cur1 | Currency | $10 |
Number and currency functions
Functions go at the start of the expression.
Function | Data type | Description | Syntax | Output |
Rand | Number | Generates a random number. | Rand() | 0.449218421 |
RandBetween | Number | Generates a random number between two values. | RandBetween(1, 10) | 4 |
Mod | Number or Currency | Shows the remainder when the dividend is divided by the divisor. If the dividend is a currency, the result is also a currency. | Mod(num1, 3) Mod(cur1, 3) | 1 $1 |
Min | Number or Currency | Shows the minimum value of a set of numbers. | Min(num1, num2) | 10 |
Max | Number or Currency | Shows the maximum value of a set of numbers. | Max(num1, num2) | 22.45 |
Methods
Methods come after the fieldID and are called up with a dot operator.
Function | Description | Syntax | Output |
round | Rounds a number up or down. Add the number of decimal places you want. | num2.round() num2.round(1) | 22 22.5 |
roundup | Always rounds a number up. Add the number of decimal places you want. | num2.roundup() num2.roundup(1) | 23 22.5 |
rounddown | Always round a number down. Add the number of decimal places you want. | num2.rounddown() num2.rounddown(1) | 22 22.4 |
ceil | Rounds up a number to the nearest unit given. If no value is given, it is treated as 1. | num2.ceil(5) | 25 |
floor | Rounds down a number to the nearest unit given. | num2.floor(5) | 20 |
abs | Shows the absolute value of a number. | num2.abs() | 22.45 |
code | Shows the currency code in a text field. | cur1.code() | USD |
Operators
There are five arithmetic operators in Kissflow:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Exponents (^)
Expressions with arithmetic operators can use integers or fields.
Using operators
Here are all the ways that you can evaluate fields.
Field 1 | Field 2 | Operator | Resulting type |
Number | Number | +, -, *, / | Number |
Number | Integer | +, -, *, /, ^ | Number |
Currency | Currency (same) | +, - | Currency |
Currency | Number/Integer | *, / | Currency |
Converting data types
Here are some ways to convert data types using numbers.
Name | Description | Syntax | Output |
value | Converts a currency value to a number value. | cur1.value() | 10 |
Number | Converts a text value to a number. E.g. the value of text1 is “10”. | Number(text1) | 10 |
Currency | Converts a number value to a specific currency. | Currency(num1, GBP) | £ 10 |
convert | Converts one currency into another type with a static exchange rate.^{1} | cur1.convert(.90, “EUR”) | EUR €9.00 |
1. To use real-time exchange rates, use a remote lookup field.