Stop 07 · BI Tools & DashboardsTopics · 6/9

Calculated Fields (Tableau)

Part of the Data Analyst Roadmap

In short

Your data has Sales and Profit but your boss asks about margin, delivery days and loyal customers. None of those are columns yet. Calculated fields create them inside Tableau.

Tableau's equivalent formula mechanism — creating new fields derived from existing ones, used constantly for custom metrics not present in the raw data.

The jaadu pours milk and tea into a steaming pot at a chai stall.

Think of it like this

Making masala chai

The chai stall has milk, tea leaves, ginger and sugar. None of them is chai. Mix them with a recipe and you get a new drink. A calculated field is a recipe that mixes existing fields into a new one you can drag onto any view.

Watch it happen

Row-level ratio vs aggregate ratio

10/100
0
10/100
1
500/1000
2

1/4Three orders shown as profit/sales: ₹10 on ₹100, ₹10 on ₹100, ₹500 on ₹1,000.

The big ideas

What you need to know

Row-level calcs

[Ship Date] minus [Order Date] style formulas run on every row before anything is summed.

Aggregate calcs

SUM([Profit]) / SUM([Sales]) runs after grouping. Use this for ratios and margins.

IF and CASE

IF [Profit] > 0 THEN "Profit" ELSE "Loss" END creates categories you can colour or filter by.

LOD expressions

{FIXED [Customer ID] : MIN([Order Date])} finds each customer's first order, whatever the view shows.

See it in code

Walk through the code

tableau
1// Profit Ratio (aggregate)2SUM([Profit]) / SUM([Sales])3 4// Days to Ship (row level)5DATEDIFF('day', [Order Date], [Ship Date])6 7// Order Health8IF [Profit] < 0 THEN "Loss"9ELSEIF [Discount] >= 0.3 THEN "Heavy discount"10ELSE "Healthy" END11 12// First Purchase Date per customer (LOD)13{ FIXED [Customer ID] : MIN([Order Date]) }

1/4Sums first, then divides. This gives the correct margin at any level of the view.

Four separate calculated fields. Each one appears in the data pane and works like any other field.

Save yourself the pain

Common mistakes

Oops

Writing [Profit] / [Sales] for margin, then using it in a chart.

Do this instead

Write SUM([Profit]) / SUM([Sales]) so big and small orders are weighted correctly.

Oops

Copying the same long IF formula into five worksheets.

Do this instead

Make it one calculated field and reuse it. Fix it once, every sheet updates.

Your mission

Three recipes

~25 min

Quick check

Which formula gives the correct overall profit margin across many orders?

Go deeper

  1. 1Create a calculated field for a simple ratio metric (e.g. profit margin).
  2. 2Practice a calculated field using an IF/CASE-style conditional.
  3. 3Compare the syntax and mental model to Power BI's DAX.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge