Skip to main content
Albero Academy

Calculated Fields in Depth

Create your own fields — row-level vs aggregate calculations, and the logical, string, date and number functions you use most.

Chapter 11Tableau16 min readBeginner friendly
  • #Tableau
  • #Calculations
  • #Functions

When your data doesn't have the field you need, you build one. Calculated fields are new fields defined with a formula — profit ratios, categories, cleaned text. Chapter 3 introduced them; this chapter is the working toolkit of function categories and the crucial row-level-vs-aggregate distinction.

Beyond the raw fields

Right-click in the Data pane → Create Calculated Field, give it a name and a formula. It becomes a new field you can drag onto shelves like any other — reusable across the whole workbook.

Row-level vs aggregate

The most important distinction, mirroring Power BI's columns-vs-measures:

two kinds of calculation
Row-level (computed per underlying row, then aggregated in the view):
[Sales] - [Cost]
[Sales] * 0.9
Aggregate (operates on the aggregated values):
SUM([Sales]) - SUM([Cost])
SUM([Profit]) / SUM([Sales]) ← a ratio must be aggregate!

Logical functions

IF, CASE, conditions
IF [Sales] > 1000 THEN "High" ELSEIF [Sales] > 500 THEN "Mid" ELSE "Low" END
CASE [Region]
WHEN "North" THEN "Priority"
ELSE "Standard"
END
IIF([Profit] < 0, "Loss", "Profit") -- shorthand for a simple 2-way IF
ZN([Value]) -- treat NULL as zero (Zero-if-Null)

String & date functions

reshaping text & dates
-- Strings
LEFT([Name], 3) UPPER([Name]) TRIM([Email])
CONTAINS([Email], "@") SPLIT([Full Name], " ", 1)
-- Dates
DATEDIFF('day', [Order Date], [Ship Date])
DATEPART('year', [Order Date])
DATETRUNC('month', [Order Date]) -- bucket to month start
TODAY()

Practice

Create a profit-ratio calculated field the correct (aggregate) way and confirm it's right at the grand total. Build a sales-band with IF/ELSEIF, extract a first name with SPLIT, and compute shipping days with DATEDIFF.

Key takeaways

  1. 01Calculated fields are new formula-defined fields, reusable across the workbook.
  2. 02Row-level calcs compute per row then aggregate; aggregate calcs operate on aggregated values.
  3. 03A ratio of measures must be aggregate: SUM(Profit)/SUM(Sales), never the row-level version.
  4. 04Logical: IF/ELSEIF/END, CASE, IIF, ZN (zero-if-null).
  5. 05String (LEFT/UPPER/SPLIT/CONTAINS) and date (DATEDIFF/DATEPART/DATETRUNC) functions reshape fields.