Understanding Data Types and Roles
Last Modified Date: 09 Apr 2013
Data types and roles are fundamental components that contribute to how Tableau categorizes your data. They also play a part in how visualizations behave. For example, the data type and role can determine the following:
- Which icon appears next to each field in the Data window.
- Which fields are categorized as dimensions and which are measures.
- Whether a field that you drag to a view creates an axis with a scale or an axis that shows discrete category headings.
When you understand data types and roles, you can use them to communicate complex data relationships more meaningfully. The remainder of this article provides an introduction to data types and roles to help you get started.
Identifying and Changing Data Types
Each field in any data source has an associated data type. For example, a field that contains customer names has a string (text) data type, and a field that contains price information usually has a numeric data type. In the Tableau environment an icon appears next to each field name listed in the Data window to indicate its data type.
In the following image, the Customer Name field as it appears in Tableau shows an Abc icon, indicating that its data type is string.
When you connect to a data source, Tableau identifies the data types for each field. However, sometimes you might want to change the data type. For example, a field that contains date information is interpreted as a numeric data type. If you connected to a relational data source, you can change the data type by completing the following step.
- In the Tableau Data window on the left side, right-click the field, select Change Data Type, and then select the new data type.
Data Roles: Dimensions and Measures
In addition to a data type, each field has an associated role. This role controls how the field behaves when you use it in a view. The most apparent roles are dimensions and measures. When you connect to a data source, Tableau identifies each field’s role by determining whether the field contains categorical data (dimension) or quantitative data (measure).
Generally, when you drag fields to views, a dimension creates an axis of category headings, and a measure creates an axis showing a continuous scale.
You can change a field’s role from measure to dimension or vice-versa by changing the data type.
- In the Data window, right-click the field, select Change Data Type, and then select the new data type.
You can change measures to dimensions or vice-versa in these additional ways:
Drag a field from one pane to the other; for example, drag an OrderID field from Measures to Dimensions.
- Right-click a field and select Convert to Dimension or Convert to Measure.
Discrete and Continuous Fields
Fields are also either continuous or discrete, and this is indicated in Tableau by color. Green indicates a continuous field; blue indicates a discrete field. Colors appear on the icons next to fields in the Data window, or on the pills that represent fields that are used in the view.
Most often, dimensions are discrete fields, and measures are continuous. Therefore, when you drag a discrete field to a view, it adds category headings. A continuous field adds a scale. This distinction exists in Tableau so that you can convert dimensions to continuous fields or measures to discrete. For example, the views below both show profit as a function of order amount. In the view on the left the order amount is shown as discrete headers, one for each value. On the right, you can see that order amount is shown along a continuous axis.
To convert a discrete field to continuous, complete the following task.
- In the Dimensions pane, right click the field and convert a its data type to Number.
- Right-click it again and select Convert to Continuous.