Data Types in Tableau – Learn to Use & Change Data Types
As Tableau is a business intelligence and data analysis tool, data is obviously at the center stage of it. Data being an important functional element of Tableau, it is important for us to learn and understand all the underlying features of it such as different data types used, how is data managed, extracted, filtered, merged, etc. in Tableau. We have separate tutorials for all of it but in this tutorial, we will be learning in detail about the different data types used in Tableau.
Keeping you updated with latest technology trends, Join DataFlair on Telegram
What are Data Types and Icons?
Data types characterize the data values into its definite type. Some data values are only text (eg. “DataFlair”) so their data type will be a string as it only contains characters. While some data values have whole numbers (eg. 5550) and so their data type is an integer. If a data value is in the form of a date or time (eg. 22/02/2019 or 03:25:40) then the data type date/time is assigned to it. In a similar way, every data value will fall under a certain category of the data type. Tableau also has a set of data types based on which it characterizes every data value present in it as field values either from a live data connection or as a data extract from the data source.
There are primarily seven data types used in Tableau. Tableau automatically detects the data types of various fields as soon as new data gets uploaded from source to Tableau and assigns it to the fields. You can also modify these data types after uploading your data into Tableau by options available in the:
- String values
- Number (Integer) values
- Date values
- Date & Time values
- Boolean values
- Geographic values
- Cluster or mixed values
In the Data pane of Tableau, each data type is denoted with a distinct icon shown in the table below. We can easily identify the data types of the fields in Tableau and also change them if we want. We will see how to change data types from different locations in Tableau in the next section. In this section, let us first make sure that we have a complete understanding of all the data types used in Tableau.
Data Types in Tableau
Let us understand each Tableau data type in detail here.
1. String Data Type
The string data type consists of zero or more characters meaning it is a text data type. A value is considered as a string when the characters are enclosed in a single or double quote (as known as single or double inverted commas). For instance, a string data value can be “DataFlair” or “DataFlair Indore” etc. You can also incorporate double inverted commas into a string for instance, ‘“Raj says Hello” ’ which will show as “Raj says Hello”.
The string data type is further divided into two categories; Char and Varchar.
- Char string type: The values of this data type have a fixed length. Memory corresponding to this fixed length is allocated to char string type values in Tableau. If you try to enter a string value with a length greater than the fixed length, then the system is going to show an error. This data type generally stores alphanumeric data values.
- Varchar string type: Varchar string type stands for variable character length where the length of the characters to be entered in a string is not fixed or predefined. You can enter as many characters as you want without having any memory allocation restrictions. This string type can also have alphanumeric data values.
2. Numeric Data Type
The numeric data type values can be either an integer type or floating type. Most fields having numeric data type are of integer type because with float values, users face difficulty in accumulating the decimal point after a certain limit. However, float values can also be used easily in calculations after rounding them up to corresponding integers. A function known as Round function is used for rounding up float values.
3. Date and Time Data Types
In Tableau, all formats of date and time are accepted such as dd-mm-yy, dd-mm-yyyy or mm-dd-yyyy, etc. Some fields can only contain a date value or a date can exist along with the time (like a timestamp). The time data values can be decade, year, quarter, month, day, hour, minutes, seconds, etc. Also, if you wish to add a date value in the form of string characters, add a # sign before it (for instance, #22 January 2020). Tableau registers date and time values under two data types which are Date data type and Date & Time data value.
4. Boolean Data Type
The boolean data type values are a result of relational calculations. Therefore, True and False boolean values are known as logical values. Sometimes, the result of a relational calculation is unknown and obscure. Such values are shown as Null values.
5. Geographic Data Type
The geographic data values are all that are used in a map. Values such as country name, state name, city, region, postal codes, etc. belong to the geographic data type. The fields of this data type are denoted by a globe icon.
6. Cluster or Mixed Data Type
Sometimes a field might not consist of a single data type and rather have a mixture of data types. This is also known as cluster group values or mixed data values. In such scenarios, either you can manually handle such fields by segregating values belonging to different data types into the column or let Tableau handle it.
Changing Data Types in Tableau
Ideally, Tableau detects and assigns respective data types to all the existing fields in a data set during fresh data upload. However, you can make changes in the data types at many stages while working in Tableau. Three of which are shown below:
1. Changing data type of a field in Data Source page
To change the data type of a field from the Data Source page, click on the data type icon of that field. A drop-down list will appear from where you can select a new data type and assign it to the values of that field.
2. Changing data type of a field from Data pane
Once a data set gets uploaded in Tableau, the underlying data fields are shown in the Data pane of a Tableau worksheet. We can also change the data type of a field from here. To do this, click on the data type icon of a field and select a new data type for the values of that field from the list that opens.
3. Changing the data type of a field in the View
Another way to change the default data type of a field is from the View. Here, right-click on the field and then select Change Data Type from the drop-down list. This will further open a list of data types from where you can select the data type of your choice as shown in the image below.
Mixed Data Types from Files in Tableau
Often times when we import data from files like MS Excel, Access, CSV, etc. the columns have mixed data types. Data values with mixed data types can have numbers and texts together or dates and numbers. Usually, whenever new data gets uploaded in Tableau, it maps the appropriate data type for the values in each column and assigns it to the column. It is a simple process when a column contains the values of a single data type. In that case, a typical date or text column is a dimension field and a numeric column is a measure field.
But when a column has more than one data type in its values, the mapping rules are a little specific for each file type.
- The data type in Excel is decided by the data type (date, text, number, boolean) of the first 10,000 rows.
- In a CSV file, the data type id decided by the data type of the first 1024 rows.
In this tutorial, we learned about different data types used in Tableau. We saw that there are seven basic data types in Tableau namely, String, Numeric, Boolean, Date, Date & time, Geographic and Mixed or cluster. Tableau is capable of detecting the data type of newly uploaded values and assigns it to them instantly. Also, here we saw how we can change the data type of a field in different ways in Tableau.
The next tutorial to explore – Tableau Dashboard
We hope you liked our tutorial on Tableau data types. Stay with us for more interesting topics on Tableau!