---
schema_version: "1"
id: 55ee808a15df215843b70c224f54325b7cb8b14ee9f1d3079046598322814bee
title: Calculated Measurement Functions
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/mktg/264-0-0/dato_measure_functions.md
canonical_url: https://help.salesforce.com/s/articleView?id=mktg.dato_measure_functions.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 3e9b29b254cb9b3cb65380755ec6861eac6cfac7d43347b9c77b9abb866b14b8
description: Use functions when creating a calculated measurement to make your functions more dynamic.
products:
  - Marketing
  - Marketing Cloud Intelligence
release: "264"
---
# Calculated Measurement Functions

Use functions when creating a calculated measurement to make your functions more dynamic.

The functions are divided into these categories:

- Number
- Text
- Date
- Aggregation
- Logical
- Type Conversion
- Context

## Number Functions

Returns a numerical value.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e80">Function Name</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e83">Syntax</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e86">Description</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">ABS</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">ABS(number)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Returns the absolute value of a number.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">CEILING</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">CEILING(number,significance)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Rounds the number up away from zero to the nearest multiple
              significance.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">EXP_TREND</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">EXP_TREND(metric)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Computes an exponential trend line for the given metric.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">FLOOR</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">FLOOR(number,significance)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Rounds the number down toward zero to the nearest multiple
              significance.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">LINEAR_TREND</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">LINEAR_TREND(metric)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Computes a linear trend line for the given metric.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">LOG_TREND</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">LOG_TREND(metric)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Computes a log trend line for the given metric.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">MOVING_AVG</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">MOVING_AVG(metric, windowSize)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Computes a moving average with the given window size. If windowSize is null or
              negative, a fully cumulative average is computed.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">POWER_TREND</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">POWER_TREND(metric)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Computes a power trend line for the given metric.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">RAND</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">RAND()</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Gets a random number between 0 and 1.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">ROUND</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">ROUND(number)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">
              <p>Rounds a number to the nearest integer. For example: ROUND(4.2) =4 </p>
              <p style="margin-bottom:0;">ROUND(4.6) =5</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">ROUND</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">ROUND(number,num_digits)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Rounds a number to a specified number of digits.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e80 ">TREND_SLOPE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e83 ">TREND_SLOPE(metric, windowSize)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e86 ">Computes the linear trend slope in the given window size. If windowSize is null
              or negative, a fully cumulative average is computed.</td>

          </tr>
        </tbody>
      </table>

## Text Functions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e271">Function Name</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e274">Syntax</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e277">Description</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">CHAR</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">CHAR(number)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Returns a character specified by a number.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">COALESCE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">COALESCE([value1, value2,...])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Returns the first value from the list that isn’t empty.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">CODE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">CODE(text)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Returns a numeric code for the first character in a text string.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">COUNT_CHAR</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">COUNT_CHAR(text,charToCount)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Counts how many times a specific character appears in a text.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">EXTRACT</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">EXTRACT(text,delimiter,position)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Extracts from the given text the substring at the given position, after
              splitting by the given delimiter. For example, EXTRACT(‘a,b,c’,’_’,1) returns
              ‘b’.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">FIND</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">FIND(findText,withinText)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">
              <p>Returns the starting position of findText withinText.</p>
              <p>For example, FIND('World', 'Hello World') returns 6.</p>
              <p style="margin-bottom:0;">FIND('aoc', 'Hello World') returns -1.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">FUZZYMATCH</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">FUZZYMATCH(valueToMatch, array, threshold)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Searches for a string in an array of values that potentially match using
              duplicate-detection algorithms that calculate the similarity of two streams of data.
              Returns the matched string from the array or an empty string if no matches are
              found. For example, FUZZYMATCH("ABC Compani",{"ABC Company Inc","Apple Inc","IBM
              Company"},0.8) returns "ABC Company Inc". The threshold parameter must be a value
              between 0 and 1. A threshold of 1 means an exact match.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">GET_EXCHANGE_RATE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">GET_EXCHANGE_RATE(date, fromISO, toISO)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">
              <p>Gets the exchange rate for the given currencies and date. </p>
              <p>The date variable in the formula can be either a mapped date field or a date
                function.</p>
              <p>For example: <code>GET_EXCHANGE_RATE([Day], 'USD', 'GBP')</code></p>
              <p>where [Day] is a mapped date field.
                <code>GET_EXCHANGE_RATE(DATE('2021','8','17'),'USD','GBP')</code>
              </p>
              <p>where DATE('YYYY','MM','DD') is a date function.
                <code>GET_EXCHANGE_RATE(YESTERDAY(),'USD','GBP')</code>
              </p>
              <p style="margin-bottom:0;">where <code>YESTERDAY()</code> is a date function.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">INDEXOF</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">INDEXOF(array, findText)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">
              <p>Searches the array for the specified item, and returns its position.</p>
              <p>Returns -1 if the item isn’t found.</p>
              <p>If the item is present more than one time, the INDEXOF function returns the
                position of the first occurence.</p>
              <p>For example, INDEXOF(csv['row'], 'Campaign ID') == 0 returns true if 'Campaign
                ID' was found in the first cell.</p>
              <p style="margin-bottom:0;">Note: The first item has position 0, the second item has position 1, and so
                on.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">ISEMPTY</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">ISEMPTY(value)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">
              <p>Returns if the value is empty or not. For example, ISEMPTY(‘ab’) returns
                false.</p>
              <p style="margin-bottom:0;">ISEMPTY(‘’) returns true.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">LEFT</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">LEFT(text,numOfChars)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Returns the requested number of characters from the left. For example
              LEFT(‘abcde’, 2) returns ‘ab’.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">LEN</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">LEN(text)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">
              <p>Returns the number of characters in the given text.</p>
              <p style="margin-bottom:0;">For example LEN(‘abc’) returns 3.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">LOWER</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">LOWER(text)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">
              <p>Converts all uppercase letters in a string to lowercase letters. For example,</p>
              <p style="margin-bottom:0;">LOWER(‘AbC’) returns ‘abc’.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">MATCH</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">MATCH(valueToMatch,array)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Searches for a specified item in an array of values and then returns a boolean
              result. For example, MATCH(1,{1,2,3}) returns true because the value '1' exists in
              the array.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">PROPER</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">PROPER(text)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Capitalizes the first letter in a text string and any other letters in text
              that follow any character other than a letter. Converts all other letters to
              lowercase.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">REPLACE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">REPLACE(SourceStr,pattern, targetStr)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Replaces every match of a pattern (a regex expression) in sourceStr to
              targetStr. For example, REPLACE('All-The-Best', '-', ' ') returns 'All The Best'.
              REPLACE('Let It Be','\\s','-') returns 'Let-It-Be'.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">RIGHT</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">RIGHT(text,numOfChars)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Returns the requested number of characters from the right. For example,
              RIGHT(‘abcde’, 2) returns ‘de’.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">SELECT</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">SELECT(sourceStr,pattern)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Selects the first match of the pattern (a regex expression) in the sourceStr.
              For example, SELECT('Hello B wow E Goodbye', 'B(.*?)E') returns 'B wow E'.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">SEMTIMEN</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">SENTIMEN(text)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Extracts a positive, neutral, or negative sentiment from the given
              text.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">SPLIT</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">SPLIT(text,delimiter)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Splits a text string into an array by using a delimiter character. It returns a
              zero-based, one-dimensional array holding the parts of the original text string. For
              example, SPLIT('a,b,c', ',') returns an array with three items.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">SUBSTITUTE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">SUBSTITUTE(text,oldText,newText)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Substitutes newText for oldText in a text string. Use SUBSTITUTE when you want
              to replace specific text in a text string.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">SUBSTRING</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">SUBSTRING(text,beginIndex,endIndex)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Returns the substring of the text beginning at beginIndex (inclusive) and
              ending at endIndex (exclusive).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">TRIM</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">TRIM(text)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Removes all spaces from the text except for single spaces between words. For
              example, TRIM('Hello World') returns 'Hello World'.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">UPPER</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">UPPER(text)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Converts all lowercase letters in a text string to uppercase. For example,
              UPPER(‘abC’) returns ‘ABC’.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">URL_DECODE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">URL_DECODE(text)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Decodes an application/x-www-form-urlencoded string using a UTF-8 encoding
              scheme.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">URL_ENCODE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">URL_ENCODE(text)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Translates a text into an application/x-www-form-urlencoded format using a
              UTF-8 encoding scheme.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e271 ">VALUE_FROM_JSON</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e274 ">VALUE_FROM_JSON(JSON string, key)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e277 ">Returns the value for a given key in a JSON string. If the key doesn’t exist or
              the JSON is empty, an empty string is returned.</td>

          </tr>
        </tbody>
      </table>

## Date Functions

  
| Function Name | Syntax | Description |
| --- | --- | --- |
| DATE | DATE(year,month) | Returns the first day of the given month in the given year. |
| DATE | DATE(year,month,day) | Returns the date representing the given arguments. |
| DATEADD | DATEADD(interval,number, date) | Returns the date after which a certain time/date interval has been added. The interval can be one of the following: 'yyyy' (year), 'q' (quarter), 'm' (month), 'd' (day), 'ww' (week), 'h' (hour), 'n' (minute), or 's' (second). |
| DATEDIFF | DATEDIFF(interval,startDate,endDate | Returns the number of time units specified by interval between the startDate and the endDate. The startDate and endDate arguments can be date objects or date strings in standard form. The interval can be one of the following: 'yyyy' (year), 'q' (quarter), 'm' (month), 'd' (day), 'ww' (week), 'h' (hour), 'n' (minute), 's' (second). For example, DATEDIFF('m', PARSEDATE('12/22/2021','MM/d/yyyy'), PARSEDATE('10/18/2021','MM/d/yyyy')) returns -2. |
| DAYPRECISION | DAYPRECISION(date) | Returns the given date with day precision,so hours, minutes, and seconds fields are all set to 0. For example, the date '12-Jun-2012 16:34' is converted to '12-Jun-2012 00:00'. |
| DAYSBETWEEN | DAYSBETWEEN(startDate,endDate) | Returns the number of days between the given startDate and endDate.The arguments can be date objects or date strings in standard form. |
| DAYSINMONTH | DAYSINMONTH(date) | Returns the number of days in a specified month. |
| NETWORKDAYS | NETWORKDAYS(startDate,endDate) | Returns the number of workdays between two dates, excluding weekends.The arguments can be date objects or date strings in standard form. |
| NOW | NOW() | Returns the current system date and time. |
| SETHOUR | SETHOUR(date,hour) | Returns the given date set with the given hours, with hour being a numeric value between 0 and 23. |
| TODAY | TODAY() | Returns the current system date. |
| TOSECONDS | TOSECONDS(duration) | Returns the amount of seconds represented by the given duration string in the format HH:mm:ss/HH:mm:ss.SSS. |
| YESTERDAY | YESTERDAY() | Returns yesterday’s system date. |

## Aggregation Functions

All aggregation functions look at a data range, as opposed to a single row. You can specify the data range you want the calculated measurement to consider by defining the set of rows that the function operates on, which is called a window function.

You can define a window function in two ways.

- Use GroupByDims within your function, for example SUM(\[metric\],\[\[groupByDims\]\])
- Use a syntax that lets you choose in which row the function begins to apply and where it stops, such as SUM(metric, first\_index(), last\_index())

If you don’t define the window function, aggregation functions consider all the data included in the query.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e914">Function Name</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e917">Syntax</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e920">Description</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">ACC</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">ACC(metric, [groupByDims], orderByDim, sortOrder)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Gives an accumulative sum of the metric grouped by the dimensions, ordered by
              the orderByDim with the given sortOrder (‘ASC’ or ‘DESC’). For example,
              ACC(‘Clicks’, [‘Media Buy Key’], ‘Day’, ‘ASC’).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">ACC</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">ACC(metric, orderByDim, sortOrder, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Gives an accumulative sum of the metric ordered by the orderByDim with the
              given sortOrder (‘ASC’ or ‘DESC’). The window is defined as an offset from the
              current row. Use first_index()+n and last_index()-n for the offsets from the first
              and last row in the partition. If the last two parameters are omitted, the entire
              partition is used.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">ACC_SUM</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">ACC_SUM(metric)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes an accumulating sum for the given metric. Unlike ACC, this function
              does not require you to insert a sort order.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">AVG</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">AVG(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the average of the given metric grouped by the supplied
              dimensions.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">AVG</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">AVG(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the average of the given metric. The window is defined as an offset
              from the current row. Use first_index()+n and last_index()-n for offsets from the
              first and last row in the partition. If the last two parameters are omitted, the
              entire partition is used.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">CORREL</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">CORREL(metric1, metric2, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Calculates the Pearson Product-Moment Correlation Coefficient for two sets of
              values. Set the appropriate precision when creating a calculated measurement using
              correlation.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">CORREL</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">CORREL(metric1, metric2, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Calculates the Pearson Product-Moment Correlation Coefficient for two sets of
              values. The window is defined as an offset from the current row. Use first_index()+n
              and last_index()-n for the offsets from the first and last row in the partition. If
              the last two parameters are omitted, the entire partition is used.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">COUNT</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">COUNT(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Counts the number of rows (grouped by the supplied dimension list) in which the
              given metric exists.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">COUNT</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">COUNT(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Counts the number of rows (grouped by the supplied dimension list) in which the
              given metric exists.The window is defined as offsets from the current row. Use
              first_index()+n and last_index()-n for offsets from the first or last row in the
              partition. If the last two parameters are omitted, the entire partition is used
              (optional).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">COUNT</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">COUNTDISTINCT([dimensions], [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Returns the number of unique appearances of dimension value combinations within
              the supplied context dimensions. If no groupBy dimensions are supplied, the row
              context is used.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">DENSE_RANK</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">DENSE_RANK([groupByDims], orderField, sortOrder)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the dense rank grouped by the dimensions, ordered by the orderField
              with the given sortOrder (‘ASC’ or ‘DESC’). If groupByDims is omitted, it is
              calculated over the entire range.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">FIRST</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">FIRST(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Returns the first value (considering the results’ date dimension) of the given
              metric, grouped by the supplied dimensions.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">FIRST</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">FIRST(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Returns the first value (considering the results’ date dimension). The window
              is defined as offsets from the current row. Use first_index()+n and last_index()-n
              for offsets from the first or last row in the partition. If the last two parameters
              are omitted, the entire partition is used..</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">GROUPCONCAT</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">GROUPCONCAT(groupedDimension,keyDimension, separator)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Concats the values of groupedDimension by keyDimension, with the separator
              string between each two grouped values. If a value is repeated, it’s not concated
              twice. For example, GROUPCONCAT({Media Buy Name}, {Campaign Name}, ',' ) results in
              all media buy names concated (with no repetitions) for each campaign.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">LAST</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">LAST(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Returns the latest value (considering the results’ date dimension) of the given
              metric, grouped by the supplied dimensions.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">LAST</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">LAST(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Returns the latest value (considering the results date dimension). The window
              is defined as offsets from the current row. Use first_index()+n and last_index()-n
              for offsets from the first or last row in the partition. If the last two parameters
              are omitted, the entire partition is used (optional).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">LIFETIME</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">LIFETIME(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the lifetime aggregation of the given metric grouped by the supplied
              dimensions.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">LIFETIME</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">LIFETIME(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the lifetime aggregation of the given metric. The window is defined as
              offsets from the current row. Use first_index()+n and last_index()-n for offsets
              from the first or last row in the partition. If the last two parameters are omitted,
              the entire partition is used (optional).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">MAX</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">MAX(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the maximum of the given metric grouped by the supplied
              dimensions.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">MAX</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">MAX(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the maximum of the given metric.The window is defined as offsets from
              the current row. Use first_index()+n and last_index()-n for offsets from the first
              or last row in the partition. If the last two parameters are omitted, the entire
              partition is used (optional).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">MEDIAN</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">MEDIAN(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Returns the median (the value lying at the midpoint of the frequency
              distribution of all the values) of a metric across all records. You can use median
              only with numeric fields. Null values are ignored.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">MEDIAN</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">MEDIAN(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">The window is defined as offsets from the current row. Use first_index()+n and
              last_index()-n for offsets from the first or last row in the partition. If the last
              two parameters are omitted, the entire partition is used. (optional).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">MIN</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">MIN(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the minimum of the given metric grouped by the supplied
              dimensions.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">MIN</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">MIN(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the minimum of the given metric. The window is defined as offsets from
              the current row. Use first_index()+n and last_index()-n for offsets from the first
              or last row in the partition. If the last two parameters are omitted, the entire
              partition is used (optional).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">PERCENTILE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">PERCENTILE(metric, number, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Returns the percentile value of the given metric corresponding to the specified
              number. The number must be between 0 and 1 (inclusive), for example, 0.66, and must
              be a numeric constant.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">PERCENTILE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">PERCENTILE(metric, number, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the percentile value of the given metric corresponding to the
              specified number. The number must be between 0 and 1 (inclusive), for example, 0.66,
              and must be a numeric constant. The window is defined as offsets from the current
              row. Use first_index()+n and last_index()-n for offsets from the first or last row
              in the partition. If the last two parameters are omitted, the entire partition is
              used (optional).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">RANK</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">RANK([groupByDims], orderField, sortOrder)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the rank grouped by the dimensions, ordered by the orderField with the
              given sortOrder (‘ASC’ or ‘DESC’). If groupByDims is omitted, it is calculated over
              the entire range.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">STDEV</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">STDEV(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the standard deviation of the given metric grouped by the supplied
              dimensions.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">STDEV</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">STDEV(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the standard deviation of the given metric. The window is defined as
              offsets from the current row. Use first_index()+n and last_index()-n for offsets
              from the first or last row in the partition. If the last two parameters are omitted,
              the entire partition is used (optional).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">SUM</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">SUM(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">
              <p>Computes the sum of the given metric grouped by the supplied
                dimensions.</p>
              <p style="margin-bottom:0;">For example, SUM(‘Clicks’, [‘Media Buy Key’, ‘Creative Key’])
                returns the sum of clicks per media buy key and creative key.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">SUM</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">SUM(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the sum of the given metric. The window is defined as offsets from the
              current row. Use first_index()+n and last_index()-n for offsets from the first or
              last row in the partition. If the last two parameters are omitted, the entire
              partition is used (optional).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">TOTAL</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">TOTAL(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">
              <p>Computes the total of the metric grouped by the supplied dimensions,
                according to its defined aggregation function.</p>
              <p style="margin-bottom:0;">For example, if a metric m
                has aggregation type MAX - TOTAL(‘m’, [Dimensions]) == MAX(‘m’,
                [Dimensions]).</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">VAR</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">VAR(metric, [groupByDims])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the variance of the given metric grouped by the supplied
              dimensions.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">VAR</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">VAR(metric, first_index(), last_index())</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Computes the variance of the given metric. The window is defined as offsets
              from the current row. Use first_index()+n and last_index()-n for offsets from the
              first or last row in the partition. If the last two parameters are omitted, the
              entire partition is used.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">first_index</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">first_index()</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Returns the number of rows from the current row to the first row in the
              partition.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">index</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">index()</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">Returns the index of the current row in the partition.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e914 ">last_index</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e917 ">last_index()</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e920 ">
              <p style="margin-bottom:0;">Returns the number of rows from the current row to the last row in the
                partition.</p>
            </td>

          </tr>
        </tbody>
      </table>

## Logical Functions

  
| Function Name | Syntax | Description |
| --- | --- | --- |
| AND | AND(condition1, condition2) | Logical AND, checks to see that both conditions are true. |
| IF | IF(condition,resultifTrue,resultifFalse) | Returns the second argument if the first argument is true, and the third argument if otherwise. |
| IFERROR | IFERROR(someExpression, number) | Returns the someExpression if it’s a valid number. Otherwise, returns a number. |
| NOT | NOT(condition) | Logical NOT, reverses the logic of its argument: true becomes false and vice versa. |
| OR | OR(condition) | Logical OR, checks to see if either one of the conditions are true. |

## Type Conversion

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e1511">Function Name</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e1514">Syntax</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e1517">Description</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">COMPRESS</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">COMPRESS(value1)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Compresses a string using gzip and returns it in base64.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">DECODE_BASE64</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">DECODE_BASE64(value1)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Decodes a string from base64.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">DOUBLE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">
              <p style="margin-bottom:0;">DOUBLE(value1)</p>
            </td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Converts a string to a double.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">ENCODE_BASE64</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">ENCODE_BASE64(value1)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Encodes a string to base64.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">FORMATDATE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">FORMATDATE(date,pattern)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Returns the string representation of the given date according to the supplied
              pattern. For example, (Fri Dec 22 00:00:00 UTC 2021) returns 22-Dec-2021.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">FORMATDATE_DEFAULT</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">FORMATDATE_DEFAULT(date)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Returns the default (yyyy-MM-dd HH:mm:ss.S) Marketing Cloud Intelligence string
              representation of the given date. For example,
              DATEADD('d',3,PARSEDATE('12/22/2021','MM/d/yyyy')) returns (Mon Dec 25 00:00:00 UTC
              2021).</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">MD5</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">MD5(stringToHash)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Returns an MD5 hash of the given string.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">NUMBER</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">NUMBER(value1)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Converts a string to a number.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">PARSEDATE</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">PARSEDATE(dateString,pattern)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Returns the date object specified by the given dateString using the given
              pattern. For example, PARSEDATE('12/22/2021','MM/d/yyyy') returnsFri Dec 22 00:00:00
              UTC 2021.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">SHA256</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">SHA256(stringToHash)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Returns a SHA256 hash of the given string.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">STRIP_HTML</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">STRIP_HTML(value1)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">
              <p style="margin-bottom:0;">Strips HTML from a string.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1511 ">UNCOMPRESS</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1514 ">UNCOMPRESS(value1)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1517 ">Uncompresses a base64 string using gzip.</td>

          </tr>
        </tbody>
      </table>

## Context Functions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e1702">Function Name</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e1705">Syntax</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d45195e1708">Description</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1702 ">CONTEXT_DIMENSION_CONTAINS</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1705 ">CONTEXT_DIMENSIONS_CONTAIN(dimension)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1708 ">Returns true if the given dimension is included in the query.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1702 ">CONTEXT_DIMENSION_EQUALS</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1705 ">CONTEXT_DIMENSIONS_EQUALS(dimension)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1708 ">Returns true if the given dimensions are exactly the context dimensions. Enter
              all relevant dimensions, but the order isn’t important.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1702 ">FilterEndDate</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1705 ">FilterEndDate()</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1708 ">Returns the end date of the query filter.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1702 ">FilterStartDate</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1705 ">FilterStartDate()</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1708 ">Returns the start date of the query filter.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1702 ">GET_ENV</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1705 ">GET_ENV(variableName)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1708 ">Returns the value for the given environment variable. Possible values are:
              WORKSPACE_ID.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1702 ">QUERY_DIMENSIONS_CONTAIN</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1705 ">QUERY_DIMENSIONS_CONTAIN(dimension)</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1708 ">Returns true if the given dimension is one of the query dimensions.</td>

          </tr>
          <tr class="">
            <td data-label="Function Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1702 ">QUERY_DIMENSIONS_EQUAL</td>

            <td data-label="Syntax" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1705 ">QUERY_DIMENSIONS_EQUAL([dimensions])</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d45195e1708 ">
              <p style="margin-bottom:0;">Returns true if the given dimensions are exactly the query dimensions. Enter all
                the relevant dimensions, but the order isn’t important.</p>
            </td>

          </tr>
        </tbody>
      </table>