Tableau Conversion Functions

Tableau provides various Type Conversion Functions to perform typecasting on our data. They are Tableau DATE, DATETIME, DATEPARSE, INT, FLOAT, SRT, etc. In this article, we show how to use Tableau Conversion Functions with examples.

To demonstrate these Tableau Conversion Functions, we use the below Excel Worksheet. So, Please refer to the Connecting to the Excel Files article.

Tableau Conversion Functions 1

Tableau Conversion Functions

The following examples will show you the list of Conversion Functions in Tableau.

Tableau STR Function

The Tableau STR function converts the given expression to a string. The syntax of this Tableau STR Function is:

STR(expression)

To demonstrate these Tableau conversion functions, we have to use Calculated Fields. To create a calculated field, please navigate to the Analysis Tab and select the Create Calculated Field… option as shown below.

tableau convert date to string 2

Once you click on the Create Calculated Field… option, a window will be opened. Here, we renamed the default calculation name as STRFunc. The below Tableau str statement will convert the Hire date to String

STR([Hire Date])
tableau convert date to string 3

Let me add this STR function field to an existing table (by dragging a field to Rows Shelf). Please refer to the Create Table Report article to understand the process of creating a table. For more built-in functions >> Click Here!

tableau convert date to string 4

Tableau DATE Function

The Tableau Date function returns a date from a given expression, number, or string. The syntax of this Tableau Date Function is:

DATE(expression)

Let me use this Tableau date function on StrFunc, which holds the Hire Date in string format.

DATE([STRFunc])
tableau convert string to date 5

From the screenshot below, you can see the Tableau Date function returned the date from the string column.

tableau convert string to date 6

Tableau DATETIME Function

The Tableau DateTime function is one of the Tableau conversion functions, which returns the date and time from a given expression, string, or number. The syntax of this Tableau Datetime Function is:

DATETIME(expression)

Let me use this Tableau DateTime function on StrFunc, which holds HireDate in string format.

DATETIME([STRFunc])
tableau convert string to date 7

Tableau INT Function

The Tableau INT function returns an integer from a given expression. The syntax of this Tableau INT Function is:

INT(expression)

Let me use this function on the Sales column, which holds Float values.

INT([Sales])
Tableau INT Function 8

Tableau FLOAT Function

The Tableau FLOAT is one of the Tableau conversion functions that converts a given expression to float. The syntax of the Tableau FLOAT Function is:

FLOAT(expression)

Let me use this Tableau float function on the income column, which has int values.

FLOAT([Income])
Tableau FLOAT Function 9

Tableau DATEPARSE Function

The Tableau Dateparse function parses and returns the date and time from a given expression, number, or string. The syntax of this Tableau Dateparse Function is:

DATEPARSE('format', expression)

Let me use this Tableau DateParse function on StrFunc, which has a string format of Hire Date. Remember, the given format should match the data inside the column

DATEPARSE('yyyy-MM-dd h:m:s.SSSS', [STRFunc])
tableau convert string to date 10