Functions
Number functions
Format number
Format a number with grouped thousands and optionally decimal digits.
{% number_format([float number], [decimal_places], [decimal_separator], [thousands_separator]) %}
Round
Round the float number based on the precision from the second parameter.
{% round([float number], [integer precision]) %}
Ceil
Rounds to the nearest integer up. E.g. 2.1 => 3.
{% ceil ([float number]) %}
Floor
Rounds to the nearest integer down. E.g. 2.8 => 2.
{% floor ([float number]) %}
Pow
Number in power of.
{% pow([float base value], [integer|float power of]) %}
Sqrt
Square root of a number.
{% sqrt ([float base value])%}
String functions
Uppercase
To display data field value in uppercase, use following expression.
{% uppercase({dataFieldName}) %}
Lowercase
To display data field value in lowercase, use following expression.
{% lowercase({dataFieldName}) %}
Capitalize
Uppercase the first character of each word in a string.
{% capitalize({dataFieldName}) %}
Split
The split(delimiter, string) function allows to split string into an array.
{% split("_", "Some_string") %} => ["Some", "string"]
Replace
The str_replace([string: search], [string: replace], [string: the original string])
function replaces all occurrences of a substring within a string.
{% str_replace("dog", "cat", "this is dog") %}
This expression output is: this is cat
Substring
The substr ( string $string , int $offset , int|null $length = null )
returns the portion of string specified by the offset and length parameters.
{% substr("This is test", 0, 2) %} // Result: Th
{% substr("This is test", 1, 2) %} // Result: hi
{% substr("This is test", -2) %} // Result: st
Count
The count({stringData}) returns the length of the string
{% count("abcd") %} // Result: 4
Date functions
Date
Format date value.
{% date({dateString}, {timezone}, {addDays}, {outputFormat}, {inputFormat}) %}
Examples of the function "Date":
- Display current time
{% date('now') %}
- Specify timezone
{% date({dateValue}, 'UTC') %}
- Specify output format
{% date({dateValue}, 'UTC', 0, 'd/m/Y') %}
- Specify output and input format
{% date({dateValue}, 'UTC', 0, 'd/m/Y', 'm/d/Y') %}
Datetime
Format datetime value.
{% datetime({datetimeString}, {timezone}, {addDays}, {outputFormat}, {inputFormat}) %}
Examples of the function "Datetime":
- Display current time
{% datetime('now') %}
- Specify timezone
{% datetime({dateValue}, 'UTC') %}
- Specify output format
{% datetime({dateValue}, 'UTC', 0, 'd/m/Y H:i:s') %}
- Specify output and input format
{% datetime({dateValue}, 'UTC', 0, 'd/m/Y H:i:', 'm/d/Y H:i:') %}
Y-m-d\THH:mm:ss
Date difference
The date_diff
function calculates a difference between two dates. You can also specify the {inputFormat}
to hint date format. If date strings use known format then it is handled automatically.
{% date_diff({datetimeString}, {datetimeString}, {inputFormat}) %}
You can use date('now')
function as the date value to find difference between today and another date.
{% date_diff(date('now'), '2021-09-15', 'Y-m-d') %}
Format | Description | Example Output |
---|---|---|
Day |
|
|
| The day of the month (two digits, leading zeros) | 01 to 31 |
| A textual representation of a day (three letters) | Mon through Sun |
| The day of the month without leading zeros | 1 to 31 |
| A full textual representation of the day | Sunday through Saturday |
| ISO-8601 numeric representation of the day (1 = Monday, 7 = Sunday) | 1 to 7 |
| English ordinal suffix for the day of the month (2 characters: st, nd, rd, or th) | 1st, 2nd, 3rd |
| Numeric representation of the day (0 = Sunday, 6 = Saturday) | 0 to 6 |
| The day of the year | 0 through 365 |
Week |
|
|
| ISO-8601 week number of year (weeks starting on Monday) | 01 to 53 |
Month |
|
|
| A full textual representation of a month | January through December |
| Numeric representation of a month (two digits, leading zeros) | 01 to 12 |
| A short textual representation of a month (three letters) | Jan through Dec |
| Numeric representation of a month (without leading zeros) | 1 to 12 |
| The number of days in the given month | 28 to 31 |
Year |
|
|
| Whether it's a leap year (1 if it is a leap year, 0 otherwise) | 0 or 1 |
| ISO-8601 year number | 2023 |
| A full numeric representation of a year (four digits) | 2023 |
| A two-digit representation of a year | 23 |
Time |
|
|
| Lowercase am or pm | am, pm |
| Uppercase AM or PM | AM, PM |
| Swatch Internet time | 000 to 999 |
| 12-hour format of an hour (no leading zeros) | 1 to 12 |
| 24-hour format of an hour (no leading zeros) | 0 to 23 |
| 12-hour format of an hour (two digits, leading zeros) | 01 to 12 |
| 24-hour format of an hour (two digits, leading zeros) | 00 to 23 |
| Minutes with leading zeros | 00 to 59 |
| Seconds, with leading zeros | 00 to 59 |
| Microseconds | 654321 |
Timezone |
|
|
| Timezone identifier | UTC, GMT, Europe/Paris |
| Whether the date is in Daylight Savings Time (1 if DST, 0 otherwise) | 0 or 1 |
| Difference to Greenwich time (GMT) in hours | +0200 |
| Difference to Greenwich time (GMT) with colon between hours and minutes | +02:00 |
| Timezone abbreviation | EST, MDT |
| Timezone offset in seconds (west of UTC is negative, east of UTC is positive) | -43200 to 50400 |
Full Date/Time |
|
|
| ISO-8601 date | 2023-01-14T23:59:59+00:00 |
| RFC 2822 formatted date | Sat, 14 Jan 2023 23:59:59 +0000 |
| Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) | 1673740799 |
List (array) functions
Count
It is possible to count number of items in list.
{% count({line_items}) > 3 ? 'More than three' : 'Less than three' %}
Max
Returns maximum value of list of elements or separate field values.
{% max({line_items::quantity}) %}
or
{% max({dataField1}, {dataField2}, ..., {dataFieldN}) %}
Min
Returns minimum value of list of elements or separate field values.
{% min({line_items::quantity}) %}
or
{% min({dataField1}, {dataField2}, ..., {dataFieldN}) %}
Sum
It is possible to calculate sum of table column using following code.
{% sum({line_items::amount}) %}
Sumproduct
The sumproduct function multiplies the corresponding items in the arrays and returns the sum of the results.
{% sumproduct({line_items::amount},{line_items::price}, {line_items::anotherColumn}) %}
Average
It is possible to calculate average of table column using following code.
{% avg({line_items::amount}) %}
Join
The join(delimiter, array) function concatenates field values with specified separator. Last argument is always used as the separator.
{% join(";", {field1}, {field2}, {field3}, ..., {fieldN}) %}
{% join(";", [{field1}, {field2}, {field3}, ..., {fieldN}]) %}
Iterate list of elements (array map)
Iterates over list of elements and executes expression for each element. Returns new list.
{% iterate({line_items}, 'quantity*price') %}
{% map({line_items}, 'quantity*price') %}
Filter list of elements
Filters a list of elements by executing the given expression for each element. Returns new list.
{% filter({line_items}, 'price > 10.1') %}
{% iterate({list}, 'value === reference', 3) %} // reference = 3
{% map({list}, 'value === reference', 3) %} // reference = 3
{% filter({list}, 'value === reference', 3) %} // reference = 3
Collect unique values from list
Collects unique values from and counts them. Returns new list with following structure:
[{"value": "Value", "count": 3, "raw_value": "Value"}, {"value": "Value 2", "count": 1, "raw_value": "Value 2"}]
{% collect_unique_values({array}, {array_of_values_to_exclude}, {expression_to_execute_for_each_item}) %}
Example use case:
This is the JSON example dataset to demonstrate the functionality of collect_unique_values function.
[{"array_of_names":[{"name":"marian"},{"name":"bruno"},{"name":"erik"},{"name":"tanel"},{"name":"michal"},{"name":"erik"},{"name":"erik"}]}]
Lets say we want to make a list of unique values from the "array_of_names" data field, but exclude the names "tanel" and "michal".
The expression to do that would look like this:
{% join(", ", iterate((collect_unique_values({array_of_names}, ["michal","tanel"], "name")), "value")) %}
Flatten list
Flattens list.
{% flatten(iterate({orders}, "{line_items}")) %}
Sort list
The function sort([array], [expression], [direction]))
allows you to sort list of elements by the key value. The direction
can be either ASC
or DESC
. The function returns new array with sorted items.
{% sort({line_items}, "quantity", "DESC") %}
{% sort({line_items}, "quantity*price", "ASC") %}
{% sort({line_items}, "quantity > 10 ? 1 : 0", "ASC") %}
Utility functions
Empty
The empty(value) checks if the variable exists and if the value is not “falsy”. Returns true if var does not exist or has a value that is empty or equal to zero, aka falsely. Otherwise, it returns false.
{% empty({dataField}) ? 'No value' : 'Field has value' %}
What qualifies as "falsy"?
- Anything that returns false if cast to boolean
- Empty array
- Zero as number
- Zero as string
- Empty string
- null
- false
- undefined
JSON decode
Decode JSON string to use in an expression.
{% json_decode('{"key": "value"}', true) %}
Example datafield:
{
"json_field": "{\"name\":\"value\"}"
}
Example expressions for JSON decode
{% json_decode({json_field}).name %}
{% json_decode({json_field}, true)['name'] %}
Related articles you may find helpful
- How to add page numbers?
- Is it possible to conditionally change the component style or hide the component?
- Text Component
Updated on: 10/04/2025
Thank you!