01 / 20
Abc 123 Date

Data Types in
Tableau

Learn to set data types correctly: string, number, date, and datetime. Master fixing parsing issues so your visualizations always work.

Tableau

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

Abc String
Text data: names, categories, IDs treated as labels. Cannot be summed or averaged.
# Number
Integers and decimals. Enables \( \text{SUM} \), \( \text{AVG} \), and all mathematical aggregations.
Date
Calendar dates (year, month, day). Powers time-series analysis and \( \text{DATEPART} \) functions.
DateTime
Date plus time (hours, minutes, seconds). Essential for precise event timestamps.

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.

1
Aggregation failures: a "Sales" column stored as String cannot be summed, only counted.
2
Broken time axes: dates stored as String won't sort chronologically or enable date hierarchies.
3
Filter confusion: numeric IDs typed as Number get aggregated instead of filtering as categories.

How Tableau Assigns Types

Data Source Scan First ~1000 Rows Infer Type Auto-detect Abc String # Number Date Calendar DateTime Timestamp Inference can be wrong! Always verify types in the Data Source tab

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

1
Data Source tab: Click the type icon above each column header (Abc, #, calendar). Select the correct type from the dropdown.
2
Data pane (sheet view): Right-click a field → Change Data Type → choose String, Number (whole), Number (decimal), Date, or Date & Time.
3
Calculated field: Use conversion functions like \( \text{INT()} \), \( \text{FLOAT()} \), \( \text{STR()} \), \( \text{DATE()} \), or \( \text{DATETIME()} \) for precise control.
4
Verify: Check the icon next to the field name: Abc = String, # = Number, calendar = Date/DateTime.

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.

Symptom
Nulls appear in numeric fields, dates show as "Null" or the wrong century.
Cause
Mixed formats ("$1,200" vs "1200"), locale mismatches (DD/MM vs MM/DD), special characters.
Fix
Clean in source, use \( \text{REPLACE()} \) + \( \text{INT()} \), or apply \( \text{DATEPARSE()} \) with explicit format strings.

The DATEPARSE Function

\( \text{DATEPARSE} \) lets you tell Tableau exactly how your date strings are formatted, fixing locale and format mismatches.

// Syntax:
\( \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.

// "$1,234.56" → 1234.56
\( \text{FLOAT} \)(
  \( \text{REPLACE} \)(
    \( \text{REPLACE} \)([Revenue], "$", ""),
    ",", ""
  )
)

// "45 kg" → 45
\( \text{INT} \)(\( \text{REPLACE} \)([Weight], " kg", ""))

Example: Sales Won't Sum

Before (String) Abc Sales "$1,200.00" "$850.50" "N/A" "$2,100.00" SUM = Error! → After (Number) # Sales 1200.00 850.50 Null 2100.00 SUM = 4,150.50

Example: Dates Out of Order

String Sort (Wrong) Abc Order Date "01/02/2024" "01/11/2024" "02/01/2024" "12/25/2023" Sorted alphabetically! Dec 2023 comes last → Date Sort (Correct) Date Order Date 12/25/2023 01/02/2024 01/11/2024 02/01/2024 Sorted chronologically ✓ Dec 2023 first

Example: Zip Codes Losing Zeros

Number Type (Wrong) # Zip Code 2101 7302 90210 10001 Leading zeros dropped! → String Type (Correct) Abc Zip Code "02101" "07302" "90210" "10001" All 5 digits preserved ✓

Common Mistakes

✕ Trusting Auto-Detect
Assuming Tableau always guesses correctly. Mixed-format columns often get typed as String when they should be Date or Number.
✕ IDs as Numbers
Leaving Customer ID or Product Code as Number. Tableau then tries to \( \text{SUM} \) or \( \text{AVG} \) them, producing meaningless results in tooltips.
✕ Ignoring Nulls
After a type change, not checking for new Null values. Dirty rows that fail conversion silently become Null and skew your analysis.
✕ Wrong Date Locale
Connecting to European-format dates (DD/MM/YYYY) on a US-locale Tableau install. March 2 becomes February 3 without warning.

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?