Skip to content
Tutorials Center
My learning

Topics

Lesson 3 of 35 ยท Welcome to Tableau

Tableau Data Types, Dimensions, Measures and Date Functions

Understand Tableau data types, dimension and measure roles, discrete (blue) and continuous (green) pills, how to change a type, and the core date functions with examples.

Most "Tableau is wrong" moments are really data-type moments. A number stored as text will not sum, a date read as a string will not make a timeline, a postal code treated as a number loses its leading zero. This lesson teaches the three ideas that prevent those problems: data type, role (dimension or measure) and discrete versus continuous.

Data types

Every field has a data type. The icon next to it in the Data pane tells you which.

Icon Type Examples
Abc String "East", "Office Supplies"
# Number (whole or decimal) 420, 0.35
Calendar Date 2025-03-09
Calendar + clock Date & Time 2025-03-09 14:30:00
T/F Boolean true, false
Globe Geographic role (a string or number with a map meaning) State, Country, Postal Code

Changing a data type

You can change a type in three places:

  1. Data pane: click the icon beside the field and pick a different type.
  2. Data Source page: click the type icon above the column in the grid.
  3. With a function: create a calculated field such as INT([Postal Code]), STR([Year]), FLOAT([Rate]), DATE([Order Date Text]) or DATEPARSE("yyyy-MM-dd", [Date String]).

Changing the type in the Data pane or on the Data Source page changes how Tableau reads the field, but not the file. A function creates a new field and leaves the original alone, which is safer when you need both.

Convert identifiers to String, not Number. A customer ID or ZIP code is a label, not a quantity. As a number it would be summed by mistake and would lose leading zeros (02134 becomes 2134).

Try it: why type matters (stand-in)

This Python stand-in reads sales values stored as text with a currency symbol. It shows why a text column cannot be summed and what the conversion does, much like FLOAT(REPLACE([Sales Text], "$", "")) in a Tableau calculated field.

Python Stand-in: text that looks like a number

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Dimensions and measures

Tableau splits fields into two roles.

  • Dimensions are categories. Strings, dates and booleans are dimensions by default. They set the level of detail: each distinct value makes a header, a bar or a group.
  • Measures are values to aggregate. Numbers are measures by default. A measure is always wrapped in an aggregation on the view, such as SUM(Sales) or AVG(Profit).

A number can be a dimension when it is a category (a year, a rating from 1 to 5, a table number). Right-click the field and choose Convert to Dimension, or drag it up into the Dimensions area. The reverse works for numeric measures only.

Tableau also creates two helper fields. Measure Names and Measure Values let you show several measures at once (one header per measure name, one axis for their values). They appear at the bottom of the Data pane. A row-count field (for example Orders (Count) or Number of Records, depending on your Tableau version) counts the rows behind each mark.

Discrete and continuous: blue and green

The second split is independent of dimension/measure.

  • Discrete fields (blue pills) are separate buckets. They produce headers: a label for each value.
  • Continuous fields (green pills) form a range. They produce axes: a scale with a continuous line.

You can switch a pill between the two by right-clicking it, so any field type can usually behave either way. The difference is visible with dates.

Pill on Columns Result
MONTH(Order Date) discrete (blue) Headers January, February... Months from all years are merged
MONTH(Order Date) continuous (green) An axis of real months, one point per month of each year
YEAR(Order Date) discrete One header per year

This is the classic first question: "Why does my line look broken?" Usually a date is discrete when it should be continuous, or the other way around. A continuous date gives a smooth line and lets you use trend lines and forecasts; a discrete date gives a bar per period.

flowchart TD
    F["A field"] --> R{"Role"}
    R -->|"Dimension"| D["Groups the data"]
    R -->|"Measure"| M["Gets aggregated"]
    D --> T1{"Discrete or continuous?"}
    M --> T2{"Discrete or continuous?"}
    T1 -->|"Blue"| H1["Header"]
    T1 -->|"Green"| A1["Axis"]
    T2 -->|"Blue"| H2["Header of values"]
    T2 -->|"Green"| A2["Axis (default)"]

Role (dimension or measure) and type (blue or green) are two different choices.

Date functions

Dates drive most dashboards. Know these functions; each takes a date part as a text string such as 'year', 'quarter', 'month', 'week', 'day', 'hour'.

TEXT
DATEPART('month', [Order Date])              // 3 (a number)
DATENAME('month', [Order Date])              // "March" (text)
DATETRUNC('month', [Order Date])             // 2025-03-01 (a date, truncated)
DATEDIFF('day', [Order Date], [Ship Date])   // number of day boundaries between
DATEADD('month', 3, [Order Date])            // three months later
MAKEDATE(2025, 3, 9)                         // builds a date
TODAY()   NOW()                              // current date / date and time

Key habits:

  • Use DATETRUNC when you need a real date (for a continuous axis or for grouping to the month). Use DATEPART when you want a number such as the month index.
  • DATEDIFF counts boundaries, not elapsed time. DATEDIFF('year', #2025-12-31#, #2026-01-01#) is 1 even though only one day passed.
  • A week starts on Sunday or Monday depending on the data source's setting; the default can be changed under Data > Date Properties.
  • Date literals in a calculation use the pound sign: #2025-03-09#.

The pill drop-down on a date field also offers a shortcut: Year, Quarter, Month, Day (date parts, discrete) and Year, Quarter, Month, Day (date truncations, continuous) with a separate section for each. Look at the green/blue header in that menu.

Try it: date functions in SQL (stand-in)

SQLite has no DATEPART, so this stand-in uses strftime and date to mirror the same ideas on the shared orders table. It is only a way to see the results Tableau's functions would produce.

SQL Stand-in: DATEPART, DATETRUNC and DATEDIFF ideas

Press Run (or Ctrl + Enter) to see the result here.

Group by the truncated month and you have exactly what a continuous monthly line draws:

SQL Stand-in: monthly totals as a continuous date

Press Run (or Ctrl + Enter) to see the result here.

Notice 2025-01 and 2026-01 stay separate. A discrete MONTH pill would merge both Januaries, which is what the first table above warned about.

Operators in calculations

You will use these in calculated fields (Lesson Calculated fields and functions goes deeper):

  • Arithmetic: + - * / % and ^ for powers
  • Comparison: = == != <> < > <= >=
  • Logic: AND, OR, NOT
  • Precedence follows normal math; use parentheses to be explicit.

Common mistakes

  • Summing an ID. Convert it to a string or set it to a dimension.
  • Mixing blue and green dates in the same workbook without knowing the difference.
  • Reading DATEDIFF as exact time. It counts boundary crossings.
  • Leaving a string date unparsed. Use DATEPARSE with the right pattern or fix it in the Data Source page.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A ZIP code column is read as a number and loses its leading zero. What is the best fix?

    Identifiers are labels, so a String type keeps leading zeros and stops Tableau from aggregating them.
  2. 2. What colour is a continuous pill and what does it create?

    Green means continuous and produces an axis; blue means discrete and produces headers.
  3. 3. Which function returns a real date truncated to the first day of the month?

    DATETRUNC returns a date value, while DATEPART returns a number and DATENAME returns text.
  4. 4. What does DATEDIFF('year', #2025-12-31#, #2026-01-01#) return?

    DATEDIFF counts how many year boundaries are crossed, and one year boundary lies between those two dates.

Summary

  • Data types decide how a field behaves; fix them early, and keep IDs as strings.
  • Dimensions group, measures aggregate; Measure Names and Measure Values show several measures at once.
  • Blue means discrete (headers), green means continuous (axis), and that choice is separate from the role.
  • Use DATETRUNC for real dates, DATEPART for numbers, and remember DATEDIFF counts boundaries.

Next: Your first visualization and Show Me