Tableau provides various Type Conversion Functions to perform type casting on our data. They are DATE, DATETIME, DATEPARSE, INT, FLOAT, SRT etc. In this article, we will show you, How to use Tableau Conversion Functions with examples.
To demonstrate these Tableau Conversion Functions we are going to use the below-shown data. As you can see, there are 15 records in this table.
Remember, this is an Excel Worksheet. So, Please refer Connecting to Excel Files article to understand the connection settings.
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 string. The syntax of this Tableau STR Function is:
To demonstrate these conversion functions, we have to use Calculated Fields. In order to create a calculated field, please navigate to Analysis Tab and select Create Calculated Field… option as shown below.
Once you click on the Create Calculated Field… option, a window will be opened. Here, we renamed the default calculation name as STRFunc.
Below statement will convert the Hire date to String
Let me add this STR function field to existing table (by dragging a field to Rows Shelf). Please refer Create Table Report article to understand the process of creating a table
Tableau DATE Function
The Tableau Date function returns date from given expression, number, or string. The syntax of this Tableau Date Function is:
Let me use this function on StrFunc which holds Hire Date in string format.
From the below screenshot, you can see the Date function returned date from string column.
Tableau DATETIME Function
The Tableau DateTime function returns date and time from given expression, string, or number. The syntax of this Tableau Datetime Function is:
Let me use this DateTime function on StrFunc which holds Hire Date in string format.
Tableau INT Function
The Tableau INT function returns an integer from a given expression. The syntax of this Tableau INT Function is:
Let me use this function on Sales column which holds Float values.
Tableau FLOAT Function
The Tableau FLOAT function converts given expression to float. The syntax of this Tableau FLOAT Function is:
Let me use this function on income column which has int values.
Tableau DATEPARSE Function
The Tableau Dateparse function parse and returns date and time from given expression, number, or string. The syntax of this Tableau Dateparse Function is:
Let me use this function on StrFunc which holds Hire Date in string format. remember, given format should match the data inside the column
DATEPARSE('yyyy-MM-dd h:m:s.SSSS', [STRFunc])