Open navigation

Reference guide: Custom fields functions

Use these functions to create custom fields in Supermetrics.


Function name
Description
Absolute
Gets the absolute value from a selected field. For example, abs(10) and abs(-10) would both have 10 as their result.
Apply date format
Converts date values to the specified format.
Concatenate
Allows you to combine text strings or fields into one single field.
Convert data type
Converts data from one type into another, and returns a default result if the change isn't possible. Learn more about our supported data types.

For example, convert a date into text by entering the value "string" in the "Type" field.
Count occurrencesCount the number of times a character or piece of text occurs in a text.
Currency conversionConvert value to specified currency using historical EOD currency rate.
Divide
Divides a field by a certain value.

For example, use it to divide "Clicks" by any given number, or by another numeric field in your data source.
Extract string with regex
Replace field value with a regular expression match. "Pattern" defines a PCRE-compatible regular expression were looking for, and "Index" the regex group index that should be used. Defaults to "1" for the first available match.
Extract substring
Extract part of a text string based on the number of characters in the string. "Start" defines which character in the string will begin the extracted text, and "Length" defines how many characters will be included in the text.

For example, setting the start to 1 and length to 5 would turn the words "Black Friday" into "Black".
Find and replace string with regex
Find and replace strings from field with a regular expression. "Pattern" defines a PCRE-compatible regular expression we're looking for, and "Replace" what the match is replaced with.
HashHash field with given algorithm. Empty strings are left intact.
Hash with keyHash field with given algorithm and secret key. Empty strings are left intact.
Lower case
Converts any text to lowercase.

For example, using it on "Black Friday" would change the text to "black friday".
Multiply
Allows you to multiply the value for a field by a given number or the value from another field.
Replace empty values
Sets a fallback value for any fields that return no data.

For example, use it to fill in fields for nameless campaigns with something like "Unknown campaign".
Return bigger value of out two
Selects the greater value from two options.

For example, if you specify a value of 100 and select a field to compare that value that has a value of 150, this function will return 150.
Return smaller value out of two
Selects the lesser value from two options.

For example, if you specify a value of 100 and select a field to compare that value that has a value of 150, this function will return 150.

Round

Rounds numbers up or down to the next closest integer.

For example, using it on a value of 5.9 would result in 6, while a value of 5.1 would result in 5.
Round down
Rounds numbers down to the next lowest integer.

For example, using it on a value of 5.9 would result in 5.

Round up

Rounds numbers up to the next largest integer.

For example, using it on a value of 5.01 would result in 6, while using it on 5.0 would result in 5.
Subtract
Subtracts a given number from a field, or use another field's values to subtract from it.

For example, use it to subtract 100 from all "Clicks", or to subtract "Costs" from "Revenue".
SumSums up the values from a field with a given number or values from another field.

For example, use it to add "Taxes" to "Net Revenue" to form a "Gross Revenue" metric.
TrimStrips whitespaces, tabs, and return carriage from the beginning and end of a field's values.
Upper caseConverts every letter in a text string to a capital letter.

For example, using it on "Black Friday" would convert the text to "BLACK FRIDAY".
Upper case first letterConverts the first letter of a text string into a capital letter.

For example, using it on "black friday" would convert the text to "Black friday". In addition, with the "All Words" setting selected, "black friday" would be converted to "Black Friday", i.e. the first letter of all words in your string would be converted to upper case.




Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.