---
schema_version: "1"
id: dc4ff480fefe289ab0610e789f84c5342896cdd87cddc54519f3089ac140ee79
title: Tableau Prep Functions Reference
collection: tableau
version: current
locale: en-gb
portal_url: https://docs.salesforce.com/tableau/current/en-gb/prep/prep_function_reference.md
canonical_url: https://help.tableau.com/current/prep/en-gb/prep_function_reference.htm
source_site: help.tableau.com
content_type: documentation
content_hash: 8a06bd8d715d3686352538dd009697c2985edf749617a8681a708c66f1815ad8
description: Reference for Tableau Prep calculation functions across categories.
---
[Skip to main content](#main-content)

# Tableau Prep Functions Reference

Tableau Prep calculation functions allow you to use calculated fields to create new data using data that already exists in your data source.

### Number functions

<table style="width: 100%;" class="simple-table"><colgroup><col style="width: 276px;"><col></colgroup><tbody><tr><th>Syntax</th><th>Description</th></tr><tr><td><code>ABS(number)</code></td><td>Returns the absolute value of the given number.<p>Examples:</p><p><code>ABS(-7) = 7
</code></p><p><code>ABS([Budget Variance])</code></p>Returns the absolute value for all the numbers contained in the Budget Variance field.</td></tr><tr><td><code>ACOS(number)</code></td><td>Returns the arc cosine of the given number. The result is in radians.<p>Example:</p><p><code>ACOS(-1) = 3.14159265358979</code></p></td></tr><tr><td><code>ASIN(number)</code></td><td>Returns the arc sine of a given number. The result is in radians.<p>Example:</p><p><code>ASIN(1) = 1.5707963267949</code></p></td></tr><tr><td><code>ATAN(number)</code></td><td>Returns the arc tangent of a given number. The result is in radians.<p>Example:</p><p><code>ATAN(180) = 1.5652408283942</code></p></td></tr><tr><td><code>ATAN2(y number, x number)</code></td><td>Returns the arc tangent of two given numbers (<code>x</code> and <code>y</code>). The result is in radians.<p>Example:</p><p><code>ATAN2(2, 1) = 1.10714871779409</code></p></td></tr><tr><td><code>CEILING(number</code>)</td><td>Rounds a number to the nearest integer of equal or greater value.<p>Example:</p><p><code>CEILING(3.1415) = 4</code></p></td></tr><tr><td><code>COS(number)</code></td><td>Returns the cosine of an angle. Specify the angle in radians.<p>Example:</p><p><code>COS(PI( ) /4) = 0.707106781186548</code></p></td></tr><tr><td><code>COT(angle)</code></td><td>Returns the cotangent of an angle. Specify the angle in radians.<p>Example:</p><p><code>COT(PI( ) /4) = 1
</code></p></td></tr><tr><td><code>DIV(integer1, integer2)</code></td><td>Returns the integer part of a division operation, in which<code> integer1</code> is divided by <code>integer2</code>.<p>Example:</p><p><code>DIV(11,2) = 5
</code></p></td></tr><tr><td><code>EXP(number)</code></td><td>Returns e raised to the power of the given number.<p>Examples:</p><p><code>EXP(2) = 7.389
EXP(-[Growth Rate]*[Time])</code></p></td></tr><tr><td><code>FLOOR(number)</code></td><td>Rounds a number to the nearest integer of equal or lesser value.<p>Example:</p><p><code>FLOOR(3.1415) = 3</code></p></td></tr><tr><td><code>HEXBINX(number, number)</code></td><td>Maps an x, y coordinate to the x-coordinate of the nearest hexagonal bin. The bins have side length 1, so the inputs may need to be scaled appropriately.<p>Example:</p><p><code>HEXBINX([Longitude], [Latitude])</code></p></td></tr><tr><td><code>HEXBINY(number, number)</code></td><td>Maps an x, y coordinate to the y-coordinate of the nearest hexagonal bin. The bins have side length 1, so the inputs may need to be scaled appropriately.<p>Example:</p><p><code>HEXBINY([Longitude], [Latitude])</code></p></td></tr><tr><td><code>LN(number)</code></td><td><p>Returns the natural logarithm of a number. Returns Null if number is less than or equal to 0.</p><p>Example:</p><p><code>LN(EXP(5)) = 5</code></p></td></tr><tr><td><code>LOG(number [, base]</code>)</td><td><p>Returns the logarithm of a number for the given base. If the base value is omitted, base 10 is used.</p><p>Example:</p><p><code>LOG(256, 2) = 8</code></p></td></tr><tr><td><code>MAX(number, number)</code></td><td>Returns the maximum of the two arguments, which must be of the same type. Returns Null if either argument is Null. <code>MAX </code>can also be applied to a single field in an aggregate calculation.<p>Examples:</p><p><code>MAX(4,7)</code><br><code>MAX(Sales,Profit)</code><br><code>MAX([First Name],[Last Name])</code></p></td></tr><tr><td><code>MIN(number, number)</code></td><td>Returns the minimum of the two arguments, which must be of the same type. Returns Null if either argument is Null. <code>MIN </code>can also be applied to a single field in an aggregate calculation.<p>Examples:</p><p><code>MIN(4,7)
</code></p><p><code>MIN(Sales,Profit)</code></p><p><code>MIN([First Name],[Last Name])
</code></p></td></tr><tr><td><code>PI( )</code></td><td><p>Returns the numeric constant pi: 3.14159.</p><p>Example:</p><p><code>PI() = 3.14159265358979</code></p></td></tr><tr><td><code>POWER(number, power)</code></td><td>Raises the number to the specified power.<p>Examples:</p><p><code>POWER(5,2) = 52 = 25
POWER(Temperature, 2)</code></p><p>You can also use the ^ symbol:</p><p><code>5^2 = POWER(5,2) = 25</code></p></td></tr><tr><td><code>RADIANS(number)</code></td><td>Converts the given number from degrees to radians.<p>Example:</p><p><code>RADIANS(180) = 3.14159</code></p></td></tr><tr><td><code>ROUND(number, [decimals])</code></td><td>Rounds numbers to a specified number of digits. The decimals argument specifies how many decimal points of precision to include in the final result. If decimals is omitted, number is rounded to the nearest integer.<p>Example:</p><p>This example rounds every Sales value to an integer:</p><p><code>ROUND(Sales)</code></p></td></tr><tr><td><code>SIGN(number)</code></td><td>Returns the sign of a number: The possible return values are -1 if the number is negative, 0 if the number is zero or 1 if the number is positive.<p>Example:</p><p>If the average of the profit field is negative, then</p><p><code>SIGN(AVG(Profit)) = -1</code></p></td></tr><tr><td><code>SIN(number)</code></td><td>Returns the sine of an angle. Specify the angle in radians.<p>Examples:</p><p><code>SIN(0) = 1.0</code></p><p><code>SIN(PI( )/4) = 0.707106781186548</code></p></td></tr><tr><td><code>SQRT(number)</code></td><td>Returns the square root of a number.<p>Example:</p><p><code>SQRT(25) = 5
</code></p></td></tr><tr><td><code>SQUARE(number)</code></td><td>Returns the square of a number.<p>Example:</p><p><code>SQUARE(5) = 25</code></p></td></tr><tr><td><code>TAN(number</code>)</td><td><p>Returns the tangent of an angle. Specify the angle in radians.</p><p>Example:</p><p><code>TAN(PI ( )/4) = 1.0</code></p></td></tr><tr><td><code>ZN(expression)</code></td><td><p>Returns the expression if it is not null, otherwise returns zero. Use this function to use zero values instead of null values.</p><p>Example:</p><p><code>ZN([Profit]) = [Profit]</code></p></td></tr></tbody></table>

### String functions

<table style="width: 100%;" class="simple-table"><colgroup><col style="width: 276px;"><col></colgroup><tbody><tr><th>Syntax</th><th>Description</th></tr><tr><td><code>ASCII(string)</code></td><td>Returns the ASCII code for the first character of string.<p>Example:</p><p><code>ASCII('A') = 65</code></p></td></tr><tr><td><code>CHAR(number)</code></td><td>Returns the character encoded by the ASCII code number.<p>Example:</p><p><code>CHAR(65) = 'A'</code></p></td></tr><tr><td><code>CONTAINS(string, substring)</code></td><td>Returns true if the given string contains the specified substring.<p>Example:</p><p><code>CONTAINS(“Calculation”, “alcu”) = true</code></p></td></tr><tr><td><code>ENDSWITH(string, substring)</code></td><td>Returns true if the given string ends with the specified <code>substring</code>. Trailing white spaces are ignored.<p>Example:</p><p><code>ENDSWITH(“Tableau”, “leau”) = true</code></p></td></tr><tr><td><code>FIND(string, substring, [start])</code></td><td>Returns the index position of <code>substring </code>in string, or 0 if the substring isn't found. If the optional argument start is added, the function ignores any instances of <code>substring </code>that appear before the index position start. The first character in the string is position 1.<p>Examples:</p><p><code>FIND("Calculation", "alcu") = 2</code></p></td></tr><tr><td><code>FINDNTH(string, substring, occurrence)</code></td><td>Returns the position of the nth occurrence of substring within the specified string, where n is defined by the occurrence argument.<p>Example:</p><p><code>FINDNTH("Calculation", "a", 2) =7</code></p></td></tr><tr><td><code>ISDATE(string)</code></td><td><p>Returns true if a given string is a valid date.</p><p>Example:</p><p><code>ISDATE("2004-04-15") = True
</code></p></td></tr><tr><td><code>LEFT(string, number)</code></td><td>Returns the left-most number of characters in the string.<p>Example:</p><p><code>LEFT("Matador", 4) = "Mata"
</code></p></td></tr><tr><td><code>LEN(string)</code></td><td>Returns the length of the string.<p>Example:</p><p><code>LEN("Matador") = 7
</code></p></td></tr><tr><td><code>LOWER(string)</code></td><td>Returns string, with all characters lower case.<p>Example:</p><p><code>LOWER("ProductVersion") = "productversion"</code></p></td></tr><tr><td><code>LTRIM(string)</code></td><td>Returns the string with any leading spaces removed.<p>Example:</p><p><code>Example: LTRIM(" Sales") = "Sales"</code></p></td></tr><tr><td><code>(MID(string, start, [length])</code></td><td>Returns the string starting at index position start. The first character in the string is position 1. If the optional argument length is added, the returned string includes only that number of characters.<p>Examples:</p><p><code>MID("Calculation", 2) = "alculation"</code></p><p><code>MID("Calculation", 2, 5) ="alcul"</code></p></td></tr><tr><td><code>PROPER(string)</code></td><td>Converts a text string so the first letter of each word is capitalised and the remaining letters are lowercase. Spaces and non-alphanumeric characters such as punctuation also act as separators.<p>Example:</p><p><code>PROPER("PRODUCT name") = "Product Name"
</code></p></td></tr><tr><td><code>REGEXP_EXTRACT(string, pattern)</code></td><td>Returns a substring of the given string that matches the capturing group within the regular expression pattern. The regular expression pattern requires exactly one capturing group<p>Example:</p><p><code>REGEXP_EXTRACT('abc 123', '[a-z]+\\s+(\\d+)') = '123'</code></p></td></tr><tr><td><code>REGEXP_EXTRACT_NTH(string, pattern, index)</code></td><td>Returns a substring of the given string using the regular expression pattern. The substring is matched to the nth capturing group, where n is the given index.<p>Example:</p><p><code>REGEXP_EXTRACT_NTH('abc 123', '([a-z]+)\\s+(\\d+)', 2) = '123'</code></p></td></tr><tr><td><code>REGEXP_MATCH(string, pattern)</code></td><td>Returns true if a substring of the provided string matches the regular expression pattern.<p>Example:</p><p><code>REGEXP_MATCH('-([1234].[ The.Market ])-', '\\[\\s*(\\w*\\.)(\\w*\\s*\\])') = true</code></p></td></tr><tr><td><code>REGEXP_REPLACE(string, pattern, replacement)</code></td><td>Returns a copy of the given string where the matching pattern is substituted with the replacement string.<p>Example:</p><p><code>REGEXP_REPLACE('abc  123', '\\s', '-') = 'abc--123'
</code></p></td></tr><tr><td><code>REPLACE(string, substring, replacement)</code></td><td>Searches string for substring and replaces it with replacement. If substring is not found, the string is not changed.<p>Example:</p><p><code>REPLACE("Calculation", "ion", "ed") = "Calculated"</code></p></td></tr><tr><td><code>RIGHT(string, number)</code></td><td>Returns the right-most number of characters in string.<p>Example:</p><p><code>RIGHT("Calculation", 4) = "tion"</code></p></td></tr><tr><td><code>RTRIM(string)</code></td><td>Returns string with any trailing spaces removed.<p>Example:</p><p><code>Example: RTRIM("Market ") = "Market"</code></p></td></tr><tr><td><code>SPACE(number)</code></td><td>Returns a string that is composed of the specified number of repeated spaces.<p>Example:</p><p><code>SPACE(1) = " "</code></p></td></tr><tr><td><code>SPLIT(string, delimiter, token number)	
</code></td><td><p>Returns a substring from a string, as determined by a delimiter extracting the characters from the beginning or end of the string.</p><p>Example:</p><p><code>SPLIT('a-b-c-d', '-', 2) = 'b'</code></p></td></tr><tr><td><code>STARTSWITH(string, substring)</code></td><td>Returns true if string starts with <code>substring</code>. Leading white spaces are ignored.<p>Example:</p><p><code>STARTSWITH(“Joker”, “Jo”) = true
</code></p></td></tr><tr><td><code>TRIM(string)</code></td><td>Returns the string with leading and trailing spaces removed.<p>Example:</p><p><code>TRIM(" Calculation ") = "Calculation"</code></p></td></tr><tr><td><code>UPPER(string)</code></td><td>Returns string, with all characters uppercase.<p>Example:</p><p><code>UPPER("Calculation") = "CALCULATION"
</code></p></td></tr></tbody></table>

### Aggregate functions

<table style="width: 100%;" class="simple-table"><colgroup><col style="width: 276px;"><col></colgroup><tbody><tr><th>Syntax</th><th>Description</th></tr><tr><td><code>AVG(expression)</code></td><td>Returns the average of all the values in the expression. AVG can be used with numeric fields only. Null values are ignored<p>Example;</p><p><code>AVG([Profit])</code></p></td></tr><tr><td><code>COUNT(expression)</code></td><td>Returns the number of items in a group. Null values are not counted.<p>Example:</p><p><code>COUNT([Customer ID])
</code></p></td></tr><tr><td><code>COUNTD(expression)</code></td><td>Returns the number of distinct items in a group. NULL values are not counted. Each unique value is counted only once.<p>Example:</p><p><code>COUNTD([Region])</code></p></td></tr><tr><td><code>MEDIAN(expression)</code></td><td>Returns the median of a single expression. MEDIAN can be used with numeric fields only. Null values are ignored.<p>Example:</p><p><code>MEDIAN([Profit])
</code></p></td></tr><tr><td><code>PERCENTILE(expression, number)</code></td><td>Aggregate calculation that returns the percentile value from the given expression corresponding to the specified number. Valid values for the number are 0 to 1. PERCENTILE([expression], 0.50) will always return the median value in the expression.<p>Example:</p><p><code>PERCENTILE([Sales], 0.90)</code></p></td></tr><tr><td><code>STDEV(expression)</code></td><td>Returns the sample standard deviation of the expression.<p>Example:</p><p><code>STDEV([Profit])</code></p></td></tr><tr><td><code>STDEVP(expression)</code></td><td><p>Returns the population standard deviation of the expression.</p><p>Example:</p><p><code>STDEVP([Profit])
</code></p></td></tr><tr><td><code>SUM(expression)</code></td><td><p>Returns the sum of all values in the expression. SUM can be used with numeric fields only. Null values are ignored.</p><p>Example:</p><p><code>SUM([Profit])
</code></p></td></tr><tr><td><code>VAR(expression)</code></td><td><p>Returns the statistical variance of all values in the given expression based on a sample of the population.</p><p>Example:</p><p><code>VAR([Height])</code></p></td></tr><tr><td><code>VARP(expression)</code></td><td><p>Returns the statistical variance of all values in the given expression on the entire population.</p><p>Example:</p><p><code>VARP([Test Score])</code></p></td></tr><tr><td><code>ZN(expression)</code></td><td><p>Returns the expression if it is not null, otherwise returns zero. Use this function to use zero values instead of null values.</p><p>Example:</p><p><code>ZN([Profit]) = [Profit]</code></p></td></tr></tbody></table>

### Type conversion functions

<table style="width: 100%;" class="simple-table"><colgroup><col style="width: 276px;"><col></colgroup><tbody><tr><th>Syntax</th><th>Description</th></tr><tr><td><code>DATE</code></td><td>Returns a date, given a number, string or date expression.<p>Example:</p><p><code>DATE("2006-06-15 14:52") = 2006-06-15</code></p><p>Note that the quotation marks are required.</p></td></tr><tr><td><code>DATETIME(expression)</code></td><td>Returns a datetime given a number, string or date expression.<p>Example:</p><p><code>DATETIME("April 15, 2004 07:59:00")</code></p><p>Note that the quotation marks are required.</p></td></tr><tr><td><code>FLOAT(expression)</code></td><td>Returns a float given an expression of any type. This function requires unformatted numbers, which means excluding commas and other symbols.<p>Example:</p><p><code>FLOAT("3")= 3.000</code></p></td></tr><tr><td><code>INT(expression)</code></td><td>Returns an integer given an expression. This function truncates results to the closest integer towards zero.<p>Example:</p><p><code>INT(8.0/3.0) = 2 or INT(-9.7) = -9</code></p></td></tr><tr><td><code>MAKEDATE(year, month, day)</code></td><td>Returns a date value constructed from a year, a month and a day of the month.<p>Example:</p><p><code>MAKEDATE(2014, 3, 18)</code></p></td></tr><tr><td><code>MAKEDATETIME(date, time)</code></td><td><p>Returns a date and time value given a date expression and a time expression.</p><p>Example:</p><p><code>MAKEDATETIME(#2012-11-12#, #07:59:00#)</code></p></td></tr><tr><td><code>MAKETIME(hour, minute, second)</code></td><td><p>Returns a time value constructed from hours, minutes and seconds.</p><p>Example:</p><p><code>MAKETIME(14, 52, 40)</code></p></td></tr><tr><td><code>STR(expression)</code></td><td><p>Returns a string given an expression.</p><p>Example:</p><p><code>STR([Age]) </code></p><p>Returns all the values of the Age measure as strings.</p></td></tr></tbody></table>

### Date functions

<table style="width: 100%;" class="simple-table"><colgroup><col style="width: 276px;"><col></colgroup><tbody><tr><th>Syntax</th><th>Description</th></tr><tr><td><code>DATEADD(date_part, interval, date)</code></td><td>Adds an increment to the specified date and returns the new date. The increment is defined by the interval and the date_part.<p>Example:</p><p><code>DATEADD('month', 3, #2004-04-15#) = 2004-07-15 12:00:00 AM</code></p></td></tr><tr><td><code>DATEDIFF(date_part, start_date, end_date, [start_of_week])</code></td><td><p>Returns the difference between two dates where start_date is subtracted from end_date. The difference is expressed in units of date_part. If start_of_week is omitted, the week start day is determined by the start day configured for the data source.</p><p>Example:</p><p><code>DATEDIFF('month', #2004-07-15#, #2004-04-03#, 'sunday') = -3</code></p></td></tr><tr><td><code>DATENAME(date_part, date, [start_of_week])</code></td><td>Returns a part of the given date as a string, where the part is defined by date_part. If start_of_week is omitted, the week start day is determined by the start day configured for the data source.<p>Example:</p><p><code>DATENAME('month', #2004-04-15#) = "April"
</code></p></td></tr><tr><td><code>DATEPARSE(format, string)</code></td><td>Converts a string to a date in the specified format.<p>Example:</p><p><code>DATEPARSE ("dd.MMMM.yyyy", "15.April.2004") = 2004-04-15 12:00:00 AM</code></p></td></tr><tr><td><code>DATEPARTT(date_part, date, [start_of_week])</code></td><td>Returns a part of the given date as an integer where the part is defined by date_part. If start_of_week is omitted, the week start day is determined by the start day configured for the data source.<p>Example:</p><p><code>DATEPART('month', #2004-04-15#) = 4</code></p></td></tr><tr><td><code>DATETRUNC(date_part, date, [start_of_week])</code></td><td>Truncates the specified date to the accuracy specified by the date_part and returns the new date. If start_of_week is omitted, the week start day is determined by the start day configured for the data source.<p>Example:</p><p><code>DATETRUNC('quarter', #2004-08-15#) = 2004-07-01 12:00:00 AM
</code></p></td></tr><tr><td><code>DAY(date)</code></td><td>Returns the day of the given date as an integer.<p>Example:</p><p><code>DAY(#2004-04-12#) = 12
</code></p></td></tr><tr><td><code>ISDATE(string)</code></td><td>Returns true if a given string is a valid date.<p>Example:</p><p><code>ISDATE("2004-04-15") = True
</code></p></td></tr><tr><td><code>MONTH(date)</code></td><td><p>Returns the month of a given date as an integer.</p><p>Example:</p><p><code>MONTH(#2004-04-12#) = 4</code></p></td></tr><tr><td><code>NOW()</code></td><td>Returns the current date and time.<p>Example:</p><p><code>NOW() = 2004-05-12 1:08:21 PM
</code></p></td></tr><tr><td><code>TODAY()</code></td><td>Returns the current date.<p>Example:</p><p><code>TODAY() = 2004-05-12</code></p></td></tr><tr><td><code>YEAR(date)</code></td><td>Returns the year of a given date as an integer.<p>Example:</p><p><code>YEAR(#2004-04-12#) = 2004
</code></p></td></tr></tbody></table>

### Logical functions

<table style="width: 100%;" class="simple-table"><colgroup><col style="width: 276px;"><col></colgroup><tbody><tr><th>Syntax</th><th>Description</th></tr><tr><td><code>IFNULL(expr1, expr2)</code></td><td>Returns <code>&lt;expr1&gt;</code> if it is not null, otherwise returns <code>&lt;expr2&gt;</code>.<p>Example:</p><p><code>IFNULL([Profit], 0)</code></p></td></tr><tr><td><code>IIF(test, then, else, [unknown])</code></td><td>Checks whether a condition is met, and returns one value if TRUE, another value if FALSE and an optional third value or NULL if unknown.<p>Example:</p><p><code>IIF([Profit] &gt; 0, 'Profit', 'Loss')</code></p></td></tr><tr><td><code>ISDATE(string)</code></td><td>Returns true if a given string is a valid date.<p>Example:</p><p><code>ISDATE("2004-04-15") = True</code></p></td></tr><tr><td><code>ISNULL(expression)</code></td><td>Returns true if the expression does not contain valid data (<code>Null</code>).<p>Example:</p><p><code>ISNULL([Profit])
</code></p></td></tr><tr><td><code>ZN(expression)</code></td><td><p>Returns the expression if it is not null, otherwise returns zero. Use this function to use zero values instead of null values.</p><p>Example:</p><p><code>ZN([Profit]) = [Profit]</code></p></td></tr></tbody></table>

### Analytic functions

<table style="width: 100%;" class="simple-table"><colgroup><col style="width: 276px;"><col></colgroup><tbody><tr><th>Syntax</th><th>Description</th></tr><tr><td><code>LAST_VALUE(expression, [return_last_non-null_value])</code></td><td>Returns the last value of the given expression, from the first row in the partition to the current row. Accepts an optional second boolean parameter to return the last non-null value.<p>Example:</p><p><code>{ ORDERBY [Row ID] ASC: LAST_VALUE([Category], true) } = returns the last non-null value of [Category]
</code></p></td></tr><tr><td><code>LOOKUP(expression, [offset])</code></td><td><p>Returns the value of the given expression in a target row, specified as a relative offset from the current row. Returns NULL if the target row cannot be determined.</p><p>The [<code>offset</code>] parameter of the <code>LOOKUP </code>function can only take a literal integer such as 1.</p><p>Example:</p><p><code>{ORDERBY [DATE] ASC : LOOKUP([SALES], -1)} </code></p><p>Returns the SALES value from the previous row.</p></td></tr><tr><td><code>NTILE(number)</code></td><td>Distributes rows in a selected partition into a specified number of groups or tiles. With this function, the set of values (6,9,9,14) distributed to 3 tiles would be assigned to the tiles (1,2,2,3) in ascending order.<p>Example:</p><p><code>{PARTITION [Customer]: {ORDERBY [Sales] ASC: NTILE(3) }}</code></p></td></tr><tr><td><code>RANK()</code></td><td>Returns the standard competition rank for the current row in the partition. Identical values are assigned an identical rank.<p>Example:</p><p><code>{PARTITION [Customer]: {ORDERBY [Sales] ASC: RANK() }}
</code></p></td></tr><tr><td><code>RANK_DENSE()</code></td><td>Returns the dense rank for the current row in the partition. Identical values are assigned an identical rank, but no gaps are inserted into the number sequence.<p>Example:</p><p><code>{PARTITION [Customer]: {ORDERBY [Sales] ASC: RANK_DENSE() }}
</code></p></td></tr><tr><td><code>RANK_MODIFIED()</code></td><td>Returns the modified competition rank for the current row in the partition. Identical values are assigned an identical rank.<p>Example:</p><p><code>{PARTITION [Customer]: {ORDERBY [Sales] ASC: RANK_MODIFIED() }}</code></p></td></tr><tr><td><code>RANK_PERCENTILE()</code></td><td>Returns the percentile rank for the current row in the partition.<p>Example:</p><p><code>{PARTITION [Customer]: {ORDERBY [Sales] ASC: RANK_PERCENTILE() }}</code></p></td></tr><tr><td><code>ROW_NUMBER()</code></td><td>Returns a unique sequential row ID to each row.<p>Example:</p><p><code>{PARTITION [Customer]: {ORDERBY [Sales] ASC: ROW_NUMBER() }}</code></p></td></tr><tr><td><code>RUNNING_AVG(expression)</code></td><td>Returns the running average of the given expression, from the first row in the partition to the current row.<p>Example:</p><p><code>{ PARTITION [Category] : { ORDERBY [Row ID] ASC : RUNNING_AVG([Sales]) } } = running average of Sales, per Category.
</code></p></td></tr><tr><td><code>RUNNING_SUM(expression)</code></td><td>Returns the running sum of the given expression, from the first row in the partition to the current row.<p>Example:</p><p><code>{ ORDERBY [Row ID] ASC : RUNNING_SUM([Sales]) } = running sum of all Sales</code></p></td></tr></tbody></table>

### Keywords

<table style="width: 100%;" class="simple-table"><colgroup><col style="width: 276px;"><col></colgroup><tbody><tr><th>Function</th><th>Description</th></tr><tr><td><code>AND</code></td><td>Performs a logical conjunction on two expressions <p>Example:</p><p><code>IF (ATTR([Market]) = "New Business" AND SUM([Sales]) &gt; [Emerging Threshold] )THEN "Well Performing"</code></p></td></tr><tr><td><code>ASC</code></td><td>Defines the ascending order for <code>ORDERBY </code>operations.<p>Example</p><p><code>{ORDERBY [Sales] ASC:RANK()}</code></p></td></tr><tr><td><code>CASE</code></td><td>Finds the first &lt;<code>value</code>&gt; that matches <code>&lt;expr</code>&gt; and returns the corresponding &lt;<code>return</code>&gt;.<p>Example:</p><p><code>CASE [RomanNumeral] WHEN "|" THEN 1 WHEN "II" THEN 2 ELSE 3 END</code></p></td></tr><tr><td><code>DESC</code></td><td>Defines the descending order for <code>ORDERBY </code>operations. <p>Example:</p><p><code>{ORDERBY [Sales] DESC:RANK()}</code></p></td></tr><tr><td><code>ELSE</code></td><td>Test a series of expressions returning the &lt;<code>then</code>&gt; value for the first true&lt;<code>expr</code>&gt;. <p>Example:</p><p><code>IF [Profit] &gt; 0 THEN 'Profitable' ELSE 'Loss' END</code></p></td></tr><tr><td><code>ELSEIF</code></td><td>Test a series of expressions returning the &lt;<code>then</code>&gt; value for the first true&lt;<code>expr</code>&gt;. Equivalent to putting an <code>if</code> statement inside an ELSE operation.<p>Example:</p><p><code>IF [Profit] &gt; 0 THEN 'Profitable' ELSEIF [Profit] = 0 THEN 'Breakeven' ELSE 'Loss' END</code></p></td></tr><tr><td><code>END</code></td><td>Terminates an operation introduced by the corresponding directive.<p>Example:</p><p><code>IF [Profit] &gt; 0 THEN 'Profitable' ELSEIF [Profit] = 0 THEN 'Breakeven' ELSE 'Loss' END</code></p></td></tr><tr><td><code>{ FIXED }</code></td><td>FIXED level of detail expressions compute values using the specified dimensions without reference to the view level of detail. <p>Example:</p><p><code>{FIXED[Customer ID]:MIN([Order Date])}</code></p></td></tr><tr><td><code>IF</code></td><td>Creates conditional statement (<code>IF</code> statement) and allows you to execute only if a condition is True.<p>Example:</p><p><code>IF [Profit] &gt; 0 THEN 'Profitable' ELSEIF [Profit] = 0 THEN 'Breakeven' ELSE 'Loss' END</code></p></td></tr><tr><td><code>NOT</code></td><td>Performs a logical negation on an expression. <p>Example:</p><p><code>IF NOT [Profit] &gt; 0 THEN "Unprofitable" END</code></p></td></tr><tr><td><code>OR</code></td><td>Performs a logical disjunction on an expression. <p>Example:</p><p><code>IF [Profit] &lt; 0 OR [Profit] = 0 THEN "Needs Improvement" END</code></p></td></tr><tr><td><code>{ ORDERBY </code>}</td><td>Defines the order to apply analytic functions. Use the optional asc | desc argument to specify ascending or descending order for each field. <p>Example:</p><p><code>{ORDERBY [Customer Name] ASC, [Sales] DESC: RANK() }</code></p></td></tr><tr><td><code>{ PARTITION }</code></td><td>Defines the group to analytic functions. ORDERBY must be inside the partition. <p>Example:</p><p><code>{PARTITION [Customer]: {ORDERBY [Sales]: RANK()}}</code></p></td></tr><tr><td><code>THEN</code></td><td>Test a series of expressions returning the &lt;<code>then</code>&gt; value for the first true&lt;<code>expr</code>&gt;. <p>Example:</p><p><code>IF [Profit] &gt; 0 THEN 'Profitable' ELSEIF [Profit] = 0 THEN 'Break even' ELSE 'unprofitable' END</code></p></td></tr><tr><td><code>WHEN</code></td><td>Finds the first &lt;<code>value</code>&gt; that matches &lt;<code>expr</code>&gt; and returns the corresponding &lt;<code>return</code>&gt;. <p>Example:</p><p><code>CASE [RomanNumberal] WHEN 'I' THEN 1 WHEN 'II' THEN 2 ELSE 3 END</code></p></td></tr></tbody></table>