Supported Functions for Calculated Elements
The following functions are supported for calculated elements by the Data Source Creation Guided Process for visualizations:
String Functions
The following string functions can be used to create Calculated Elements:
Function Name | Description | Syntax | Example |
---|---|---|---|
uppercase | Converts an array of strings to uppercase and concatenates them into one string. | uppercase(string1) | uppercase("hello", "world") returns "HELLOWORLD" |
lowercase | Converts an array of strings to lowercase and concatenates them into one string. | lowercase(string1) | lowercase("HELLO", "WORLD") returns "helloworld" |
concatenate | Concatenates an array of strings into a single string. | concatenate(string1, string2, ...stringN) | concatenate("hello", " ", "world") returns "hello world" |
concat | Concatenates two strings into a single string.
| concat(string1, string2) | concat("hello", "world") returns "helloworld" |
substr | Extracts a substring from the given string starting at the specified position and optionally ending at the specified position. | substr(string, startIndex, endIndex) | substr("hello world", 0, 5) returns "hello" |
size | Returns the length of the given string. | size(string) | size("hello") returns 5 |
strip | Removes leading and trailing whitespace from the given string. | strip(string) | strip(" hello world ") returns "hello world" |
Mathematical Functions
The following mathematical functions can be used to create Calculated Elements:
Function Name | Description | Syntax | Example |
---|---|---|---|
round | Rounds a number to the specified number of decimal places. | round(number, precision) | round(3.14159, 2) returns "3.14" |
ceil | Rounds a number upwards to the nearest integer with the specified number of decimal places. | ceil(number) | ceil(3.14159) returns "4" |
floor | Rounds a number downwards to the nearest integer with the specified number of decimal places. | floor(number) | floor(3.14159) returns "3" |
add | Adds a series of numbers together. | add(number1, number2) | add("1", "2", "3") returns "6" |
multiply | Multiplies a series of numbers together. | multiply(number1, number2) | multiply("2", "3", "4") returns "24" |
subtract | Subtracts a series of numbers from the first number. | subtract(number1, number2) | subtract("10", "3", "2") returns "5" |
divide | Divides the first number by the product of the rest of the numbers. | divide(number1, number2) | divide("10", "2", "2") returns "2.5" |
pow | Raises the first number to the power of the second number. | pow(base, exponent) | pow("2", "3") returns "8" |
max | Returns the maximum value from an array of numbers. | max(number1, number2, ...numberN) | max("1", "3", "2") returns "3" |
min | Returns the minimum value from an array of numbers. | min(number1, number2, ...numberN) | min("1", "3", "2") returns "1" |
Comparison Functions
The following comparison functions can be used to create Calculated Elements:
Function Name | Description | Syntax | Example |
---|---|---|---|
lt | Checks if the first value is less than the second value. | lt(value1, value2) | lt("2", "3") returns "1" (true) |
lte | Checks if the first value is less than or equal to the second value. | lte(value1, value2) | lte("2", "3") returns "1" (true) |
eq | Checks if the first value is equal to the second value. | eq(value1, value2) | eq("2", "2") returns "1" (true) |
gte | Checks if the first value is greater than or equal to the second value. | gte(value1, value2) | gte("3", "2") returns "1" (true) |
gt | gt: Checks if the first value is greater than the second value. | gt(value1, value2) | gt("3", "2") returns "1" (true) |
Date Functions
The following date functions can be used to create Calculated Elements:
Function Name | Description | Syntax | Example |
---|---|---|---|
date | Extracts the day of the month from a given date string. | date(date) | date("2024-11-06") returns "6" |
month | Extracts the month (0-11) from a given date string. | month(date) | month("2024-11-06") returns "10" |
year | Extracts the year from a given date string. | year(date) | year("2024-11-06") returns "2024" |
datediff | Calculates the difference between two dates in milliseconds. | datediff(date1, date2) | datediff("2024-11-06", "2024-11-05") returns "86400000" |
dateadd | Adds a specified number of days to a date. | dateadd(date, days) | dateadd("2024-11-06", "5") returns "2024-11-11" |
quarter | Returns the quarter (1-4) of the year for the given date. | quarter(date) | quarter("2024-12-16") returns 4 |
day | Returns the day of the month for the given date. | day(date) | day("2024-12-16") returns 16 |
weekday | Returns the day of the week (0-6) for the given date, where 0 is Sunday. | weekday(date) | weekday("2024-12-16") returns 1 |
hour | Returns the hour (0-23) of the day for the given date. | hour(date) | hour("2024-12-16T15:30:00Z") returns 15 |
minute | Returns the minute (0-59) of the hour for the given date. | minute(date) | minute("2024-12-16T15:30:00Z") returns 30 |
Conditional Function
The following conditional function can be used to create Calculated Elements:
Function Name | Description | Syntax | Example |
---|---|---|---|
if | Returns a value based on a condition. If the first parameter is truthy, return the second parameter; otherwise, return the third parameter. | if(condition, valueIfTrue, valueIfFalse) | if(1==2, "Yes", "No") returns "No" |
Special Functions
The following special functions can be used to create Calculated Elements:
Function Name | Description | Syntax | Example |
---|---|---|---|
today | Gets today's date with time as 00:00:00. | today() | today() returns the current date |
now | Gets today's date with current time. | now() | now() returns the current date and time |
See Also
Supported Conditions for Data Types
Last Published Friday, April 11, 2025