Link datasets together to build online systems.
A formula can be used in a calculated column and will be automatically calculated for every row in the dataset.
To enter a formula, the column type must be set to Formula.
When a formula refers to a column, use "col" and the column ID number. In the example above the column ID for Sales is 2, so in the formula we use "col2".
Note: Whenever column is used in a formula, a constant value can also be used.
A formula can be as simple as
Formulas can contain numbers, text, and functions including
Arguments for a formula are encased in round brackets ( ) and separated by commas.
e.g. =ROUND(col2,1)
will take values from the column that has ID 2 and round them to 1 decimal place.
The text operator "+" can be used to concatenate text values in columns and text constants
Example: if col1 contains "Live" then the result of formula =col1+"Dataset" is "LiveDataset"
Simple math operators can be used
Operator | Description |
---|---|
+ | Add |
- | Subtract |
* | Multiply |
/ | Divide |
() | Use to specify precedence |
Precedence examples:
=100+400/200 following normal mathematical convention, division takes precedence and is calculated first
=100+2 =102
=(100+400)/200 as ( ) specifies the addition should take precedence it is calculated before dividing by 200
=500/200 =2.5
Math functions should be used on columns containing numbers.
Function | Example | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ABS(column) Absolute values of numbers in the column. |
Formula: =ABS(col1)
|
||||||||||||
CEILING(column) Rounds up numbers in the column. |
Formula: =CEILING(col1)
|
||||||||||||
FLOOR(column) Rounds down numbers in the column. |
Formula: =FLOOR(col1)
|
||||||||||||
MAX(column, column) The maximum value from the columns. |
Formula: =MAX(col1,col2)
|
||||||||||||
MIN(column, column) The minimum value from the columns. |
Formula: =MIN(col1,col2)
|
||||||||||||
ROUND(column) Rounds numbers in the column to the nearest integer. |
Formula: =ROUND(col1)
|
||||||||||||
ROUND(column,[places]) Rounds numbers in the column to the number of places specified. |
Formula: =ROUND(col1,1)
|
||||||||||||
VALUE(column) Extracts the numerical value from text. |
Formula: =VALUE(col1)
|
Text functions should be used on columns containing text.
Function | Example | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
LEFT(column, length) The first text characters from text values in the specified column. length specifies the number of characters. |
Formula: =LEFT(col1,4)
|
|||||||||||||||||||||||
MID(column, start, length) Returns text characters from the specified column. start specifies the starting point. length specifies the number of characters. |
Formula: =MID(col1,5,4)
|
|||||||||||||||||||||||
RIGHT(column, length) The last text characters from the end of text values in the specified column. length specifies the number of characters. |
Formula: =RIGHT(col1,3)
|
|||||||||||||||||||||||
LEN(column) Calculates the number of characters in the specified column. |
Formula: =LEN(col1)
|
|||||||||||||||||||||||
TRIM(column) Removes leading and trailing spaces from a specified column. |
Formula: =TRIM(col1)
|
|||||||||||||||||||||||
SEARCH(column, column, [startnum]) The index of the first column text inside the second column text. startnum specifies the start position in the text to search. Optional, defaults to 1 if not specifed. |
Formula: =SEARCH(col1, col2)
|
|||||||||||||||||||||||
TEXT(column) Converts numbers into text. |
Formula: =TEXT(col1) + col2
|
|||||||||||||||||||||||
SUBSTITUTE(text, to_replace, replace_with, [nth]) text, to_replace, replace_with are either fixed text, or a text column. nth is an integer. Replaces (substitutes) occurrences of what is specified in the to_replace parameter that is found within the text parameter with what is specified in the replace_with parameter. If nth is not present, it will replace all occurrences, if it is present, it will only replace the nth occurrence, where the first occurance is 1. |
Formula: =SUBSTITUTE(col1, col2, col3)
Formula: =SUBSTITUTE(col1, col2, col3, col4)
|
|||||||||||||||||||||||
UPPER(column) Converts text to uppercase. |
Formula: =UPPER(col1)
|
|||||||||||||||||||||||
LOWER(column) Converts text to lowercase. |
Formula: =LOWER(col1)
|
Date functions should be used on columns containing dates.
Function | Example | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DATEDIF(column, column, value) The number of seconds, minutes, hours, days, months or years between dates. Second column dates are 'subtracted' from first column. value must be one of:
|
Formula: =DATEDIF(col1,col2,"M")
|
||||||||||||||||||||||||
MINUTE(column) The minute of the hour as a number. |
Formula: =MINUTE(col1)
|
||||||||||||||||||||||||
HOUR(column) The hour of the day as a number. The value will be displayed in UTC time zone for consistency across users. |
Formula: =HOUR(col1)
|
||||||||||||||||||||||||
DAY(column) The day of the month as a number. |
Formula: =DAY(col1)
|
||||||||||||||||||||||||
DAYADD(column, value or column) Adds a number of days to a date. Use negative values to subtract days. |
Formula: =DAYADD(col1,col2)
|
||||||||||||||||||||||||
MONTHADD(column, value or column) Adds a number of months to a date. Use negative values to subtract months. |
Formula: =MONTHADD(col1,col2)
|
||||||||||||||||||||||||
TIMEADD(column, value or column, value or column) Adds a number of hours and minutes to a date. Use negative values to subtract days. |
Formula: =TIMEADD(col1,col2,col3)
|
||||||||||||||||||||||||
EOMONTH(column, value or column) Returns the last day of the month, after adding or removing a month offset. Use negative values to subtract months. |
Formula: =EOMONTH(col1,col2)
|
||||||||||||||||||||||||
MONTH(column) The month for the dates in the column as a number. |
Formula: =MONTH(col1)
|
||||||||||||||||||||||||
WEEKDAY(column) The day of the week for the dates in the column. result a number from 1 to 7. |
Formula: =WEEKDAY(col1)
|
||||||||||||||||||||||||
WEEKNUM(column) The number of the week for the dates in the column. result a number from 1 to 53. |
Formula: =WEEKNUM(col1)
|
||||||||||||||||||||||||
YEAR(column) The year for the dates in the column as a number. |
Formula: =YEAR(col1)
|
List and multiselect functions should be used on columns containing lists or multiple values.
Function | Example | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
COUNTMATCHES(column, value...) The number of values in the column that match the list provided. |
Formula: =COUNTMATCHES(col1,"a","b","c")
|
||||||||||
SIZE(column) Number of values in the column. |
Formula: =SIZE(col1)
|
Function | Example | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
IF(condition, true, false) Tests a condition and returns value from true or false. condition must include one of:
false is the value to return if condition is not met. TIP You can compare dates, numbers, and text. |
Formula: =IF(col1>100,col1/100,0)
|
||||||||||||||||||||||||||||||||||||||||||||||
LINK(url) A hyperlink to the url. url can be constructed using other functions. |
Formula: =LINK("http
|
||||||||||||||||||||||||||||||||||||||||||||||
VLOOKUP(dataset.column, criteria) Returns values from another dataset where criteria match between the current dataset and the other dataset. dataset.column is specified as "ds"dataset id."col"column id e.g. use ds111.col2 for column 2 in dataset 111. criteria is specified as dataset.column=column to find matching values between a column in the other dataset with a column in the current dataset. You can include multiple criteria. TIP Be careful to avoid creating a circular reference. |
Other dataset (dataset id=111)
=VLOOKUP(ds111.col2,ds111.col1=col1)
So "USA" in current dataset is looked up in currencies dataset and returns "$USD". This is similar to performing a join between database tables. TIP A quick way to find a dataset id is to look at its url. |
||||||||||||||||||||||||||||||||||||||||||||||
ROLE(dataset.group) Checks if the current user is part of a group within a people dataset. dataset.group is specified using the id of the dataset and group: "ds"dataset id."view_"view id e.g. use ds111.view_abc for group abc in people dataset 111. This function will also check the if the user has manually excluded the group from their roles. |
Formula: =ROLE(ds111.view_abc)
|