Built-in Functions
These built-in functions can be used inside any element that accepts data expressions (text elements, table cells), by enclosing them in curly braces {}
.
For example:
The formula above uses the built-in SUM function to add up the values in the total
data field.
Aggregates
Aggregate functions compute the result of a computation over a range of rows. The first argument is the name of the data field, and the second argument is the path to the array that provides the source rows.
SUM
Returns the sum of the values in the fieldName
field in all rows inside the current section's data source.
COUNT
Returns the count of non-null values, including duplicates, in the fieldName
field in all rows inside the the current section's data source.
If fieldName
is a calculation, returns the number of rows for which the calculation returns true
.
COUNTDISTINCT
Works the same way as COUNT
, but only one occurrence of each distinct value will be counted. For example,
the COUNTDISTINCT
of a list (A, B, A, B, C, B, C) is 3 (A, B, and C).
AVERAGE
Returns the average of the values in the fieldName
field in all rows inside the current group, if any, or all rows in the current data source if not currently inside a group.
MEDIAN
Returns the median of the values in the fieldName
field in all rows inside the current group, if any, or all rows in the current data source if not currently inside a group.
MIN
Returns the minimum of the values in the fieldName
field in all rows inside the current group, if any, or all rows in the current data source if not currently inside a group.
MAX
Returns the maximum of the values in the fieldName
field in all rows inside the current group, if any, or all rows in the current data source if not currently inside a group.
Other Functions
DATE
If no arguments are provided, returns today's date as a JavaScript date. If a dateStr
argument is provided, parses the string to return the corresponding date. By default, the date format 'YYYY-MM-DD' is used for parsing. If the date string is in a different format, the format string may be provided as a second argument.
Examples
FORMAT
Formats the given number or date into a string, using the specified format string.
Examples
NOW
Equivalent to DATE with no arguments. Returns the current date and time as a JavaScript Date.
TODAY
Equivalent to DATE with no arguments. Returns the current date and time as a JavaScript Date.