Data Types in
Tableau
Learn to set data types correctly: string, number, date, and datetime. Master fixing parsing issues so your visualizations always work.
What Are Data Types?
A data type tells Tableau how to interpret and store each field in your data source. Just like a spreadsheet cell can hold text, a number, or a date, every column in Tableau has a type that determines what operations you can perform on it.
The Four Core Types
Why Types Matter
Setting the wrong data type causes silent errors: Tableau won't show an error message, but your calculations, filters, and visualizations will produce incorrect results.
How Tableau Assigns Types
String vs. Number: Key Distinction
| String (Abc) | Number (#) | |
|---|---|---|
| Example Values | "New York", "SKU-4012" | 42, 3.14, -7 |
| Default Role | Dimension | Measure |
| Aggregation | \( \text{COUNT} \) / \( \text{COUNTD} \) only | \( \text{SUM} \), \( \text{AVG} \), \( \text{MIN} \), \( \text{MAX} \), etc. |
| Sort Order | Alphabetical (\( \text{"9"} > \text{"10"} \)) | Numeric (\( 10 > 9 \)) |
| Use For | Labels, categories, IDs | Quantities, measurements |
Date vs. DateTime
| Date | DateTime | |
|---|---|---|
| Stores | Year, Month, Day | Year, Month, Day + Time |
| Example | 2024-03-15 | 2024-03-15 14:30:00 |
| Granularity | Day-level minimum | Down to seconds |
| DATEPART | \( \text{YEAR} \), \( \text{MONTH} \), \( \text{DAY} \) | + \( \text{HOUR} \), \( \text{MINUTE} \), \( \text{SECOND} \) |
| Best For | Daily reports, trends | Event logs, real-time data |
How to Change Data Types
Fixing Parsing Issues
Parsing issues occur when Tableau cannot convert a value from one type to another. Common symptoms include null values appearing where data should exist, or the type icon showing Abc for a column you expected to be numeric.
The DATEPARSE Function
\( \text{DATEPARSE} \) lets you tell Tableau exactly how your date strings are formatted, fixing locale and format mismatches.
\( \text{DATEPARSE} \)("format_string", [date_field])
// Example: "15-Mar-2024" → Date
\( \text{DATEPARSE} \)("dd-MMM-yyyy", [Order Date])
// Example: "03/15/2024 2:30 PM" → DateTime
\( \text{DATEPARSE} \)("MM/dd/yyyy h:mm a", [Timestamp])
Cleaning Numeric Strings
When numbers arrive with currency symbols, commas, or units, Tableau reads them as strings. Strip the clutter first, then cast to number.
\( \text{FLOAT} \)(
\( \text{REPLACE} \)(
\( \text{REPLACE} \)([Revenue], "$", ""),
",", ""
)
)
// "45 kg" → 45
\( \text{INT} \)(\( \text{REPLACE} \)([Weight], " kg", ""))
Example: Sales Won't Sum
Example: Dates Out of Order
Example: Zip Codes Losing Zeros
Common Mistakes
Data Type Cheat Sheet
| Type | Icon | Use When | Convert With |
|---|---|---|---|
| String | Abc | Labels, categories, IDs | \( \text{STR()} \) |
| Number (int) | # | Whole counts, quantities | \( \text{INT()} \) |
| Number (dec) | #.# | Prices, ratios, measures | \( \text{FLOAT()} \) |
| Date | Cal | Daily trends, YEAR/MONTH | \( \text{DATE()} \) / \( \text{DATEPARSE()} \) |
| DateTime | Cal+T | Timestamps, event logs | \( \text{DATETIME()} \) / \( \text{DATEPARSE()} \) |
Question 1 of 5
A column called "Phone Number" contains values like 5551234567. What data type should it be in Tableau?
Question 2 of 5
You notice that a "Revenue" field shows \( \text{COUNT} \) instead of \( \text{SUM} \) in the default aggregation. What is the most likely cause?
Question 3 of 5
Your date column has values formatted as "15-Mar-2024" but Tableau reads them as strings. Which function and format string would you use?
Question 4 of 5
After changing a column from String to Number, several rows show Null that previously had values. What should you do?
Question 5 of 5
A European data source uses \( \text{DD/MM/YYYY} \) format. On your US-locale Tableau install, the date "05/03/2024" is interpreted as May 3 instead of March 5. How do you fix this?