Tableau-Functions-_-Cheat-Sheet_241204_195926

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Tableau Functions Number Functions Logical Calculations

CHEAT SHEET CEILING(1.2) = 2 Round up numbers Logical Conditions


FLOOR(1.2) = 1 Round down numbers
ROUND(1.2) = 1 Round numbers to nearest integer IF [Sales] >1200 THEN "High" Classifies Sales as "High" if greater than 1200,
END and NULL otherwise

IF [Sales] >1200 THEN "High"


Classifies Sales as "High" if greater than 1200, and "Low"
String Functions ELSE "LOW"
END
otherwise

IF [Sales] >1200 THEN "High"


Calculation Components ELSEIF [Sales] >500 THEN "Medium"
ELSE "LOW"
Classifies Sales as "High" if greater than 1200, "Medium" if
between 500 and 1200, and "Low" otherwise
END
IIF ([Sales] >1200,"High","Low") Classifies Sales as "High" if greater than 1200, and "Low"
otherwise
CASE [Country]
WHEN "Germany" THEN"DE"
Assigns country codes "DE" for Germany, "US" for USA, and
WHEN "USA" THEN "US" "n/a" for other countries
ELSE "n/a"
END

LOWER("Paris") = "paris" Converts all characters to lowercase Logical Operators


UPPER("Paris") = "PARIS" Converts all characters to uppercase
IF [Sales] > 1200 OR [Country] = "Germany" THEN "High"
LTRIM(" Paris ") = "PARIS "
Calculation 4 Types
Removes any leading spaces
END
RTRIM(" Paris ") = " PARIS" Removes any trailing spaces Classifies Sales as "High" if greater than 1200 or if the country is Germany, and NULL otherwise
Perform calculations at the row level individually. Data will not be TRIM(" Paris ") = "PARIS" Removes both leading & trailing spaces
Row-Level-Calculations
aggregated and out of calculation will be stored in data source LEFT("Paris",2) = "Pa" Extracts the left-most number of characters in string
IF [Sales] > 1200 OR [Country] = "Germany" THEN "High"
Aggregate the rows at the dimension level used in the VIZ
RIGHT("Paris",2) = "is" Extracts the right-most number of characters in string
END
Aggregate Calculations
Extracts specified number of characters in string, starting at specified
MID("Paris",2,2) = "ar" position
Classifies Sales as "High" if greater than 1200 and if the country is Germany, and NULL otherwise
Aggregate the rows at the dimension level used in the calculation to
LOD Calculations
control the level of details CONTAINS("Paris","ar") = true Returns true if the given string contains a specified substring

Table Calculation
Performed after the execute of aggregate calculation. The calculations
are performed on the data displayed in the visualization
STARTSWITH("Paris","Pa") = true
ENDSWITH("Paris","ar") = true
Returns true if string starts with substring.
Returns true if the given string ends with the specified substring
Aggregate Calculations
FIND("Baraa","a") = 2 Returns the position of substring in string
SUM([Sales]) Returns the total sum of all values
Returns the position of the nth occurrence of substring within the
FINDNTH("Baraa","a",2) = 4 specified string AVG([Sales]) Returns the average of all values
SPLIT("a-b","-",2) = b Returns a substring from a string based on specified delimiter and MAX([Sales]) Returns the maximum values
t k b MIN([Sales]) Returns the minimum value
Replaces occurrences of a specified substring with another substring
REPLACE("a-b","-","+") = b within a string COUNT([ID]) Counts the number of values
COUNTD([ID]) Counts the number of unique values
ATTR([Customer]) If all values are same, then it returns single value, otherweise Asterisk *
Date Functions
DATEPART('month',#2025-08-20#) = 8 Extracts a specific part of date as an integer
DATENAME('month',#2025-08-20#) = "August" Extracts a specific part of date as a string LOD Calculations
MONTH(#2025-08-20#) = 8 Extracts the month of a given date as an integer
Sums the sales using only category, ignoring other
{ FIXED[Category] : SUM([Sales]) }
YEAR(#2025-08-20#) = 2025 Extracts the year of a given date as an integer dimensions in the view
DAY(#2025-08-20#) = 25 Extracts the day of a given date as an integer
{ EXCLUDE[Category] : SUM([Sales]) } Sums the sales using view dimensions and excluding
category if present in the view
DATETRUNC('month',#2025-08-20#) = 2025-08-01 Truncates a date or time to a specified level of
precision
DATEADD('month',3,#2025-08-20#) = 2025-11-20 Adds an increment to specified date and returns { INCLUDE[Customer] : SUM([Sales]) } Sums the sales using not only view dimensions but also
includes the dimenion customer
Basic Components of Calculations DATEDIFF('month',#2025-11-25#,#2026-02-01#) = 3
TODAY() = 2024-08-20
Returns the difference between two dates
Returns the current date
NOW() = 2024-08-20 1:08:21 PM Returns the current date and time
Table Calculations
FIRST()
NULL Functions
Returns the number of rows from current row to first row in partition
LAST() Returns the number of rows from current row to last row in partition
INDEX() Returns the index of the current row in the partition
ZN(NULL) = 0 Converts NULL to Zero
RANK(SUM([Sales]), Ranks the total sales in descending order, assigning a rank to each row
IFNULL(NULL,1) = 1 Converts NULL to the specified value
ISNULL(NULL) = true Return true if value is NULL, and false otherwise RUNNING_SUM(SUM([Sales])) Calculates the running sum of the total sales, providing a cumulative sum
as moving

You might also like