top of page
Search
• Bernard K

# 35 Frequently Used Tableau Functions

Updated: May 18, 2021

Tableau functions help you perform computations on data, manipulate data values, create new fields and even determine whether certain conditions are True or False.

In this post, I'll explore 35 frequently used Tableau functions;

1. ABS– This function is used to return the absolute value of a given number.

• Syntax: ABS (number)

• E.g. ABS (-2) =2

2. CEILING – This function rounds a number to the nearest integer of equal or greater value.

• Syntax: CEILING (number)

• E.g. CEILING (9.124) = 10

3. FLOOR – This functions rounds a number to the nearest integer of equal or lesser value.

• Syntax: FLOOR (number)

• E.g. FLOOR (9.124) =9

4. MAX– This function returns the maximum value of two arguments.

• Syntax: MAX ( number, number)

• E.g. MAX (45, 23) = 45

5. MIN – This function returns the minimum value of two arguments.

• Syntax: MIN ( number, number)

• E.g. MIN (7, 4) = 4

6. ROUND – This function rounds numbers to the specified number of digits.

• Syntax: ROUND (number, [decimals])

• E.g. ROUND (3.125, 2) = 3.13

7. SQRT– This function returns the square root of a number.

• Syntax: SQRT (number)

• E.g. SQRT (25) =5

8. SQUARE – This function returns the square of a number.

• Syntax: SQUARE (number)

• E.g. SQUARE (6) =36

9. ZN– This function returns the target expression if it is not null otherwise returns zero.

• Syntax: ZN (expression)

10. CONTAINS – This function returns true if a given string contains the specified substring.

• Syntax: CONTAINS (string, substring)

• E.g. CONTAINS (“Tableau”, “ea”) = true

11. ENDSWITH – This function returns true if a given string ends with the specified substring.

• Syntax: ENDSWITH(string, substring)

• E.g. ENDSWITH (“Tableau”, “Zn”) = false

12. LEFT – This function returns the left most characters in the string.

• Syntax: LEFT (String, number)

• E.g. LEFT (“Water”, 3) = “Wat”

13. RIGHT – This function returns the right most characters in the string.

• Syntax: RIGHT (String, number)

• E.g. RIGHT (“Water”, 3) = “ter”

14. LEN – This function returns the length of a string.

• Syntax: LEN (string)

• E.g. LEN (“Tableau”) = 7

15. LOWER – This function returns a string with all characters in lower case.

• Syntax: LOWER (String)

• E.g. LOWER (“Water”) = “water”

16. UPPER – This function returns a string with all characters in upper case.

• Syntax: UPPER (String)

• E.g. UPPER (“tableau”) = “TABLEAU”

17. LTRIM – This function returns a string with leading spaces removed.

• Syntax: LTRIM( String)

• E.g. LTRIM (“ Water ”) = “Water ”

18. RTRIM – This function returns a string with trailing spaces removed.

• Syntax: RTRIM(String)

• E.g. RTRIM (“ Water “) = “ Water”

19. TRIM– This function returns a string with both leading and trailing spaces removed.

• Syntax: TRIM(String)

• E.g. TRIM (“ Water “) = “Water”

20. REPLACE – This function searches a string for a substring and replaces it with a replacement.

• Syntax: REPLACE (String, substring, replacement)

• E.g. REPLACE (“Tableau Desktop”, “Desktop”, “Public”) = “Tableau Public”

21. STARTSWITH– This function returns true if a string starts with the specified substring.

• Syntax: STARTSWITH (String, Substring)

• E.g. STARTSWITH (“Tableau”, “Tab”) = true

22. DATEADD – This function returns the specified date with the specified number of interval added to the specified date_part of that date.

• Syntax: DATEADD (date_part, interval, date)

• E.g. DATEADD (‘month’, 2, #28/03/2020#) = 28/05/2020

23. DATEDIFF – This function returns the difference between date1 and date2 expressed in units of date_part.

• Syntax: DATEDIFF (date_part, date1, date2)

• E.g. DATEDIFF (‘day’,#10/03/2020#, #25/03/2020#) = 15

24. DATENAME – This function returns the date_part of a date as a string.

• Syntax: DATENAME (date_part, date)

• E.g. DATENAME (‘month’, #20/04/2020#) = “April”

25. DATEPART – This function returns the date_part of a date as an integer.

• Syntax: DATENAME (date_part, date)

• E.g. DATEPART (‘month’, #20/04/2020#) = 4

26. DATETRUNC – This function truncates the specified date to the accuracy specified by the datepart.

• Syntax: DATETRUNC (date_part, date)

• E.g. DATETRUNC (‘quarter’, #27/02/2020#) = 01/01/2020 or DATETRUNC (‘quarter’, #29/06/2020#) = 01/04/2020

29. DAY/MONTH/YEAR – This functions returns the day or month or year of the specified date as an integer.

• Syntax: DAY (date) or MONTH (date) or YEAR (date)

• E.g. DAY (#28/02/2020#) =28 , MONTH (#28/02/2020#) =2, YEAR (#28/02/2020#) = 2020

30. ISDATE – This function returns true if a string is a valid date.

• Syntax: ISNULL (string)

• E.g. ISNULL (“May 10, 2019) = true

31. MAKEDATE – This function is used a create a date field from the specified year, month and day.

• Syntax: MAKEDATE (year, month, day)

• E.g. MAKEDATE (2020, 10, 24) = #24/10/2020#

32. NOW– This function returns the current date and time.

• Syntax: NOW ()

• E.g. NOW () = 14/03/2020 10:58:02 AM

33. TODAY – This function returns the current date.

• Syntax: TODAY ()

• E.g. TODAY () = 14/03/2020

34. AND– This function performs a logical conjunction on two expressions.

• Syntax: If <expr1> AND <expr1> THEN <then> END

• E.g. If [Product]=”Food” and SUM([Profit])>1,000 then “Most profitable” END

35. CASE– Case function performs logical tests and returns appropriate values.

Syntax: CASE < expression>

when <value1> then <return1>

when <value2> then <return2>

else <default return> END

E.g. CASE [Region]

When ‘East’ then 1

When ‘South’ then 2

When ‘West’ then 3

ELSE 4 END

36. ELSEIF – This function tests a series of expressions returning the <then> value for the first true <expr>.

• Syntax: If <expr> THEN <then> ELSEIF <expr2> THEN <then2> …. ELSE <then3> END

• E.g. If [Profit]>0 then ‘Profitable’ ELSEIF [Profit]<0 then ‘Non profitable’ else ‘No change’ END

I hope this post was helpful to you. To receive more of the Tableau tips and tricks, kindly subscribe to our mailing list below.

Thank you for reading.

## Comments

About Me

### Bernard K

#### Analytics Consultant | 3X Tableau Certified

Bernard is a data analytics consultant helping businesses reveal the true power of their data and bring clarity to their reporting dashboards. He loves building things and sharing knowledge on how to build dashboards that drive better outcomes.

Let’s discuss your data challenges! Let’s work together!

bottom of page