Calculations in Tableau
Your data has a column for Sales and a column for Profit. Your manager does not ask for those. She asks, “What is our profit ratio?” That number, profit divided by sales, is not sitting in any column. You have to build it. A calculated field is how you build it.
Why this matters
The most useful numbers in business are rarely the ones already in your spreadsheet. Raw columns tell you what happened: units sold, dollars collected, dates. The numbers people decide on are usually made from those raw columns. Profit ratio. Percent of total. Growth since last year. Average order value. Each one is a small formula on top of what you already have.
A calculated field lets you write that formula once and reuse it everywhere. You define it, name it, and it behaves like any other field in your data. You can drag it onto a chart, filter by it, or color by it. You built it, so it is yours to reuse.
This is the hardest chapter in the track, so we go slowly. Read it once for the shape of things. You do not need to memorize function names. Tableau shows them to you as you type.
What a calculated field is
A calculated field is a new field you create with a formula. Tableau does the math for every row or every group and hands back a new value you can use like any other field.
Think of a spare column in a spreadsheet where you type a formula at the top and it fills down for every row. A calculated field is that idea, with more power and a proper editor.
You write these formulas in the Calculation Editor. To open it, choose Analysis > Create Calculated Field from the top menu. A box appears. You give the field a name at the top, type your formula in the large area below, and click OK. Your new field shows up in the Data pane on the left with an equals sign in front of it, which marks it as calculated.
Try It Build a profit ratio from scratch.
- Open a workbook that has Sales and Profit fields. Tableau’s built-in “Sample - Superstore” data has both.
- From the top menu, choose Analysis > Create Calculated Field.
- Name it
Profit Ratio.- In the formula area, type:
SUM([Profit]) / SUM([Sales])- Click OK.
- Drag your new Profit Ratio field onto a chart, for example next to a list of product categories on Rows.
What did you notice? You now have a percentage that never existed as a column. Right-click the field and format it as a percentage to finish the job.
The building blocks: functions
A function is a small built-in command that does one job. You give it something, it hands something back. Tableau has hundreds. You only need a handful to start. Here are four families that cover most everyday work.
Before the examples, one bit of grammar. Square brackets mean “the field named this.” So [Sales] means the Sales field. You will see brackets in almost every formula.
Arithmetic: plain math
You combine fields with +, -, *, and /.
[Price] * [Quantity]
This multiplies the price of an item by how many were bought, giving the line total.
([Sales] - [Cost]) / [Sales]
This is a margin. Sales minus cost is profit. Divided by sales, it shows the share of each dollar you keep.
Logical: sorting rows into buckets
Logical functions make decisions. The IF function checks a condition and returns different answers depending on the result.
IF [Sales] >= 1000 THEN "Large order"
ELSEIF [Sales] >= 100 THEN "Medium order"
ELSE "Small order"
END
Read it top to bottom. If sales are at least 1000, label the row “Large order.” If not, but at least 100, “Medium order.” Otherwise “Small order.” ELSEIF handles the middle case, ELSE is the catch-all, and END closes the formula.
CASE does a similar job when you are checking one field against a list of exact values.
CASE [Region]
WHEN "West" THEN "Team A"
WHEN "East" THEN "Team B"
ELSE "Team C"
END
This assigns each region to a sales team. CASE stays tidy when every branch checks the same field.
Text: cleaning and shaping words
A string is text: a name, a city, a product code. String functions tidy or reshape text.
UPPER([Customer Name])
Turns “jane doe” into “JANE DOE.”
TRIM([Product Code])
Removes stray spaces at the start and end, so “ A100 “ becomes “A100.” Handy for data that arrived messy.
Dates: working with time
Business runs on dates. Date functions pull time apart and measure gaps.
YEAR([Order Date])
Returns just the year, like 2026, so you can group sales by year.
DATEDIFF('day', [Order Date], [Ship Date])
Counts the days between two dates. Here it tells you how long each order took to ship. The first part, 'day', is the unit. You could put 'month' or 'year' there instead.
The one idea that trips everyone up: row-level vs aggregate
This is the concept worth slowing down for. It explains most confusing results.
Some calculations happen row by row. Some happen after Tableau adds numbers up. The order matters, and it changes the answer.
Row-level means Tableau does the math on every single record first, before combining anything.
[Profit] / [Sales]
This divides profit by sales on each individual order, then combines those tiny per-order ratios across the group on your chart. A pile of small ratios stuck together rarely means anything to a business.
Aggregate means Tableau adds the fields up first, then does the math once on the totals. SUM is an aggregate function. It means “add these up.”
SUM([Profit]) / SUM([Sales])
This totals all the profit, totals all the sales, then divides once. For a real profit ratio, this is the number you want.
Same fields, different answer. When your ratio looks strange, this is the first thing to check.
Table calculations: math across what you can see
A table calculation is a special kind of calculation. It does its math on the numbers already showing in your chart, using the visible table rather than the hidden data underneath.
Picture a table of monthly sales on your screen. A running total adds each month to the ones before it, so you watch the year build up. That is a table calculation. It only knows about the months in view.
Common table calculations, in plain terms:
- Running total: adds each value to the sum of the ones before it. Sales to date.
- Percent of total: shows each value as a share of the whole. This region is 22% of company sales.
- Rank: orders items from highest to lowest. Your top ten products.
- Difference: shows how much a value changed from the one beside it. Up 400 units from last month.
Tableau offers these as Quick Table Calculations. Right-click a number already on your chart, choose Quick Table Calculation, and pick one.
Direction: Compute Using
Here is the part to handle with care. A table calculation moves in a direction, and you choose which.
Imagine a grid with months across the top and regions down the side. A running total could add up across the months, left to right, or down the regions, top to bottom. Same calculation, very different meaning.
Tableau calls this setting Compute Using. It decides which way the calculation walks through your table: across, down, or within panes. If a running total or a percent looks wrong, the direction is almost always the reason. Right-click the field, choose Compute Using, and try the other direction.
A gentle first look at LOD expressions
Level of Detail expressions, usually shortened to LOD, are the advanced tool in this chapter. We introduce them so the words feel familiar later. You do not need to master them today.
Here is the problem they solve. Normally a calculation works at the level of detail of your chart. If your chart shows sales by region, your numbers come out per region. Sometimes you want a number fixed at a different level, no matter what the chart shows.
Example: total sales per customer, across their whole history, even while you are looking at a chart broken down by month. An LOD expression pins the calculation to the customer level.
{FIXED [Customer Name] : SUM([Sales])}
Read the curly braces as “hold this steady.” FIXED names the level to lock to, here each customer. After the colon comes the math, total sales. The result is each customer’s lifetime sales, and it stays put even if your chart slices the data other ways.
There are three flavors: FIXED, INCLUDE, and EXCLUDE. FIXED locks to the level you name. INCLUDE and EXCLUDE nudge the level down or up from your current chart. FIXED is the one to learn first.
LOD expressions are powerful and worth revisiting once calculated fields feel comfortable. For now, recognizing the curly braces and knowing that FIXED means “compute at this level” is plenty.
In business
A regional manager for a coffee chain wants one dashboard answer: which stores punch above their weight?
She builds three calculated fields.
Profit ratio, to see which stores keep the most of each dollar:
SUM([Profit]) / SUM([Sales])
A size label, so she can group stores fairly:
IF SUM([Sales]) >= 500000 THEN "Flagship"
ELSE "Neighborhood"
END
And a share-of-region figure, using a Percent of Total quick table calculation on store sales, so a small store’s 8% stands out next to a flagship’s 30%.
With those three, she sorts by profit ratio inside each size label and finds two neighborhood stores quietly outperforming flagships. None of that lived in a raw column. She built every number.
Common pitfalls
Row-level when you meant aggregate. Writing [Profit] / [Sales] and expecting a company profit ratio. That divides on every order first, then jams the results together. Use SUM([Profit]) / SUM([Sales]) to total first and divide once. When a ratio looks off, check this before anything else.
Wrong table-calc direction. A running total that resets in odd places, or a percent of total that does not add up to 100%, almost always means Compute Using points the wrong way. Right-click the field, open Compute Using, and switch across to down, or the reverse.
Reaching for LODs too soon. LOD expressions are tempting because they sound impressive. Most everyday questions are answered by a plain calculated field or a quick table calculation. Try those first. Save LODs for when you genuinely need a number pinned to a level your chart does not show.
Forgetting the closing END. Every IF and CASE formula must finish with END. Tableau warns you at the bottom of the editor, so read the message when a formula will not save.
Practice
- Build a profit ratio field with
SUM([Profit]) / SUM([Sales])and put it on a chart by product category. Format it as a percentage. - Write an IF field that labels orders “Large,” “Medium,” or “Small” by sales amount. Use it to color a chart.
- Take any measure on a chart and apply a Percent of Total quick table calculation. Change its Compute Using direction and watch the numbers move. Notice which direction actually answers your question.
- Create the field
{FIXED [Customer Name] : SUM([Sales])}and drop it on a view. Compare it to a plain sum of sales and describe, in one sentence, how they differ.
Part of the Tableau track. Developed with AI assistance and reviewed by a human editor. Tableau changes often; menu names, features, and prices may have shifted since the “checked on” dates in this chapter. Verify anything critical against Tableau’s official documentation.
© 2026 Bastean AI Solutions, a DBA of Bastean, LLC. All rights reserved.