Changing data types

Depending on the data source and connection, Tableau tries to determine the field data type. Most often, the field data types are identified correctly; sometimes, however, changing data types becomes necessary.

Getting ready

We will use the sample superstore sales saved data source for this exercise. Open a new worksheet and connect to the Sample – Superstore Sales (Excel) data source.

How to do it....

Once the sample file is loaded on the worksheet, perform the following steps to convert data types:

  1. In the Dimensions pane, right-click on Order Date.
    How to do it....
  2. You'll notice some data types in Tableau: Number, String, and Date. Date & time is also a type, which is suited for data with a timestamp.
  3. Select String as the data type for this field. Next to this field name, you'll notice a symbol with letters (Abc); this symbol indicates that this field contains data of type String.
  4. Drag the Order Date field from the Dimensions to the Measures pane.
  5. You'll notice in the Measures pane that the field Order Date has an aggregation of Count.
  6. Right-click on Order Date (Count) in the Measures pane and select Change Data Type. Select Date as the new data type.
  7. You'll notice that the Order Date field is back in the Dimensions pane.

How it works...

Since the data type and role of a field (dimension or measure) determines how the data will be used in the visualizations, it is critical to have the right data type for fields in the data. You will notice that, if you convert a field in the Measures pane to a Date type, that field will be moved to Dimensions. If a field from the Dimensions pane is converted to Number, it will stay in the Dimensions pane. If a field from the Measures pane is converted to String, the default aggregation changes to Count.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset