Calculation Refresh Part One

After 78 days in the Data School i refresh my knowledge about calculations.

Aggregation

SUM
Returns the sum of the numbers of a measure (zero values are ignored). Tableau uses the aggregation sum by default.

AVG
Returns the average of the numbers of a measure (zero values are ignored).

MEDIAN
Returns the arithmetic mean of the numbers of a measure (zero values are ignored).

MIN
Returns the smallest number of a measure or continuous dimension (zero values are ignored).

MAX
Returns the largest number of a measure or specific expression based on a sample population.

ATTR
Returns the value of the particular expression if it has only one value for all rows in the group. Otherwise, an asterisk (*) is displayed. Null values are ignored. This aggregation is especially useful when aggregating a dimension.

COUNT/ COUNTD
This aggregation counts records differently. A record has 100 rows containing 20 different products.  COUNTD() counts the Products field, returning the value 20. While count counts all records, so it returns 100.

STDEV
Returns the standard deviation of all values in a given expression based on an unbalanced population. Assumes that the arguments include the entire population.

VAR  Returns the variance of all values in a specified expression based on an example (zero values are ignored).

Text/String fields

LEFT, RIGHT, MID / LEFT(string, number) /RIGHT(string,number) / MID(string, start, [length])

Returns the left/right part of a string with the given number of characters.
LEFT("DataSchool", 4) = "Data" / RIGHT("DataSchool", 4) = "hool".

Returns the string starting at the index position start. The first character in the string is position 1. If the optional argument length is added, the returned string contains only the specified number of characters.
MID("DataSchool", 2) = "ataSchool" / MID ("DataSchool", 2,5)= "ataS".

SPLIT / SPLIT(string, delimiter, token number)

Returns a substring from a string and divides the string into a sequence of tokens using delimiters. The string is interpreted as an alternating sequence of delimiters and tokens. For example, for the string abc-defgh-i-jkl with the separator '-', the tokens are abc, defgh, i, and jkl. Think of them as tokens 1 through 4. SPLIT returns the tokens according to their token number. If the token number is positive, the tokens are counted from the left end of the string. If the token number is negative, they are counted from the right end.
SPLIT ("D-A-T-A","-",2) = "A" / SPLIT ("D|A|T|A","|",-2) ="T".

CONTAINS / CONTAINS(string, substring)

Returns TRUE if the string contains the specified substring.
CONTAINS (dataschool", "ash"" = true

FIND / FIND(string, substring, [start])


Returns the index position of substring in string, or 0 if substring is not found. If the optional start argument is added, the function ignores all substring instances that occur before the index position start. The first character in the string is position 1.
FIND("dataschool", "atasc") =2 / FIND("dataschool", "teacher") = 0

REGEXP_REPLACE / REGEXP_REPLACE(string, pattern, replacement)

Returns a copy of a given string, replacing the regular expression pattern with the replacement string. For Tableau data extracts, the pattern and replacement must be constants.
REGEXP_REPLACE('Data School', '\s', '-') = 'Data School'.

Logical

IF / IF  THEN  [ELSEIF  THEN ...] [ELSE ] END

Checks a series of expressions and returns the value  for the first true expression ().

ELSEIF / IF  THEN  [ELSEIF  THEN ...] [ELSE ] END
Checks a series of expressions and returns the value  for the first true expression ().

CASE / CASE  WHEN  THEN  WHEN  THEN  ... ELSE  END

Executes logical tests and returns corresponding values. CASE is easier to use than IIF or IF THEN ELSE. While an IF function is used to perform a series of arbitrary tests, a CASE function is used to look for a match for an expression. However, a CASE function can always be written as an IF function, although the CASE function is usually more accurate.

IFNULL / IFNULL(expr1, expr2)

Returns the expression  unless it is null; otherwise, returns the expression .

ISNULL / ISNULL(expression)

Returns true if the expression is NULL (contains no valid data).

Author:
Kerstin Möller
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab