Day 02 Part 1 — Tableau Basics¶
Tableau is the other dominant BI tool — known for beautiful visualisations and intuitive drag-and-drop. This session covers connecting data, the dimensions/measures model, building views, calculated fields, and dashboards.
Learning Objectives¶
- Connect to data and understand Tableau's data model
- Distinguish dimensions vs measures, continuous vs discrete
- Build charts by dragging fields to shelves
- Write calculated fields and table calculations
- Assemble an interactive dashboard
Core Concepts¶
| Term | Meaning |
|---|---|
| Dimension | Categorical field — used to slice/group (blue) |
| Measure | Numeric field — gets aggregated (green) |
| Continuous | Green pill — draws an axis (a range of values) |
| Discrete | Blue pill — creates headers (distinct values) |
| Mark | A single data point (a bar, dot, line segment) |
| Shelf | Where you drag fields: Rows, Columns, Filters, Marks |
Dimensions vs Measures — the mental model
Dimensions answer "by what?" (by region, by month, by category). Measures answer "how much?" (sum of sales, count of orders, average profit). You drag dimensions to define the structure and measures to fill in the numbers.
Connecting Data¶
- Connect → choose source (Excel, Text File, PostgreSQL, etc.)
- Data Source tab: drag tables to create joins or relationships
- Live vs Extract:
- Live — queries the source in real time (always current, can be slow)
- Extract — a fast in-memory snapshot (
.hyperfile). Use for performance.
Building Your First View¶
Double-click or drag fields: - Drag a dimension to Columns (e.g., Order Date) - Drag a measure to Rows (e.g., Sales) — Tableau auto-aggregates to SUM - Tableau picks a chart; refine with the Show Me panel (top right)
Columns: [Order Date] → time on the x-axis
Rows: [SUM(Sales)] → revenue on the y-axis
Result: a line chart of revenue over time
Common drag patterns:
| Want | Drag |
|---|---|
| Bar chart | Dimension → Columns, Measure → Rows |
| Line (trend) | Continuous Date → Columns, Measure → Rows |
| Scatter | Measure → Columns, Measure → Rows |
| Heatmap | Dimension → Columns, Dimension → Rows, Measure → Color |
| Map | Geographic field → double-click |
Calculated Fields¶
// Profit margin
Profit Margin = SUM([Profit]) / SUM([Sales])
// Order size category
Order Size =
IF [Sales] > 300 THEN "Large"
ELSEIF [Sales] > 100 THEN "Medium"
ELSE "Small"
END
// Date difference
Shipping Days = DATEDIFF('day', [Order Date], [Ship Date])
Table Calculations¶
Table calculations compute across the rows displayed in the view (not the underlying data):
// Running total
RUNNING_SUM(SUM([Sales]))
// Percent of total
SUM([Sales]) / TOTAL(SUM([Sales]))
// Previous value (like SQL LAG)
LOOKUP(SUM([Sales]), -1)
// Year-over-year growth
(SUM([Sales]) - LOOKUP(SUM([Sales]), -1)) / LOOKUP(SUM([Sales]), -1)
Level of Detail (LOD) Expressions¶
LOD expressions compute at a different grain than the view — essential for customer-level metrics on transaction data:
{ FIXED [Customer ID] : SUM([Sales]) } // each customer's total, on every row
{ INCLUDE [Product] : AVG([Price]) } // add a dimension to the detail
{ EXCLUDE [Region] : SUM([Sales]) } // remove a dimension from the detail
Filters¶
- Dimension filter: limit which categories show (drag field to Filters)
- Measure filter: filter by value range
- Context filter: right-click → Add to Context (other filters depend on it)
- Quick filter: right-click field → Show Filter (gives users interactive control)
Building a Dashboard¶
- Click the New Dashboard tab (bottom)
- Set the size (fixed, automatic, or range)
- Drag worksheets onto the canvas
- Add filters and connect them: right-click filter → Apply to Worksheets → Selected
- Add Dashboard Actions (Dashboard menu → Actions) for interactivity — filter, highlight, or URL actions
Tableau vs Power BI (Quick Comparison)¶
| Tableau | Power BI | |
|---|---|---|
| Strength | Visualisation flexibility, design | Data modelling (DAX), Microsoft integration |
| Cost | Higher | Lower (M365 ecosystem) |
| Learning curve | Intuitive start | DAX is harder |
| Best for | Design-heavy, large data | Microsoft shops, self-service |
Practice Exercises¶
Warm-up 1. Connect to a project dataset. Build a bar chart of sales by category. 2. Create a line chart of sales over time. 3. Add a filter for region and show it as a quick filter.
Main 4. Create a calculated field for profit margin. Display it by category. 5. Build a map of sales by state/country. 6. Assemble a dashboard with 3 worksheets and a shared filter.
Stretch 7. Use an LOD expression to show each customer's total spend alongside individual orders. 8. Create a dashboard action so clicking a region on a map filters the other charts.
Interview Questions¶
[Beginner] What is the difference between a dimension and a measure in Tableau?
[Beginner] What is the difference between a Live connection and an Extract?
[Mid-level] What is the difference between a calculated field and a table calculation?
[Mid-level] What is a Level of Detail (LOD) expression and when would you use FIXED?
[Senior] When would you recommend Tableau over Power BI for a client, and vice versa?