Tableau Calculated Fields Tutorial: How to Create & Syntax
Learn how to create calculated fields in Tableau. Master row-level vs aggregate formulas, avoid 'cannot mix aggregate' errors, and use IF/THEN functions.
Calculated fields extend your source without ETL — the analyst's way to add Cost, margin, or rounded metrics that the source query missed. Using Superstore data from script 06, this guide moves from creation to aggregation to formatting, with syntax you can copy. For pill context see Tableau Data Types and Roles and for connection see Tableau Connecting Data Sources.
How do you create a calculated field?
Right-click > Create > Calculated Field Tableau Help: Create Calculated Field. Steps:
- In Data pane, right-click a measure or empty area > Create Calculated Field.
- Name it (e.g.,
Cost). - Type the formula using
[Field]brackets and functions. - Click Validate; green check means syntax is valid.
- Drag the new field (icon shows
= #) to Rows, Columns or Marks.
The editor's autocomplete and function pane reduce typos — use them instead of typing freeform.
What is the Cost example — row vs aggregate?
Row-level and aggregate forms answer different questions Tableau Help: Aggregation.
// Row-level: computes per underlying row
[Sales] - [Profit] // cost per row (then aggregated by Tableau on drop)
// Aggregate: computes after grouping by view
SUM([Sales]) - SUM([Profit]) // total sales minus total profit for the viz grainIf your view is by Category, the aggregate form returns one Cost per Category. The row-level form is aggregated again by Tableau (default SUM). Both are valid, but mixing SUM([Sales]) - [Profit] triggers "Cannot mix aggregate and non-aggregate" — a classic interview trap see LOD guide.
Toggle Analysis > Aggregate Measures to see granular vs summarised behaviour.
How do MIN and MAX define ranges?
Bounds per partition Tableau Help: Aggregation.
MIN([Sales])
MAX([Sales])
MIN([Order Date])Drag Product Name to Detail and add MIN([Sales]) and MAX([Sales]) to Tooltip: you now show per-product transaction bounds. In the script at 4:28, MIN/MAX are used to spot outlier products with unusually high maximum sales.
Use with categorical filters: per Region, MAX reveals the top transaction that drives the SUM — useful before you aggregate to Tableau Table Calculations.
| Feature / Criteria |
|---|
How do CEILING and FLOOR clean reporting?
Standardise decimals for stakeholders Tableau Help: Number Functions.
CEILING([Profit]) // 681.76 -> 682
FLOOR([Profit]) // 681.76 -> 681
ROUND([Profit], 0) // nearest integerScript demo at 7:45 rounds reporting values to integers. Use the Format pane after calculated field creation to set custom decimal display — but prefer calculation-level rounding when the value will be exported to CSV.
Gotcha: SUM Inside MIN/MAX
Writing MAX(SUM([Sales])) fails because Tableau's syntax is MAX([Sales]) at row grain or WINDOW_MAX(SUM([Sales])) for table calc. Nesting SUM inside MIN/MAX confuses row vs table aggregation. Keep row-level inside MIN/MAX and wrap Table Calc functions separately — confusion here is the top error at ₹5–10 LPA technical screens.
Common errors and quick reference
| Error | Cause | Fix |
|---|---|---|
| Cannot mix aggregate and non-aggregate | SUM([Sales]) - [Profit] | Use both aggregated: SUM([Sales]) - SUM([Profit]) |
| SUM inside MAX | MAX(SUM([Sales])) | Use MAX([Sales]) or WINDOW_MAX |
| Red syntax on brackets | [Sales missing ] | Autocomplete brackets |
| Task | Formula | Note |
|---|---|---|
| Cost | SUM([Sales]) - SUM([Profit]) | Icon =# confirms calculated field |
| Range per product | MIN([Sales]), MAX([Sales]) | Add to Tooltip by product |
| Round up | CEILING([Sales]) | For clean stakeholder tables |
Next: make those fields interactive with Tableau Parameters Dynamic Filters Top-N, master the comprehensive framework in our Tableau Complete Guide, or control grain via Tableau Level of Detail Expressions.
Master Tableau Formulas & Logic
Practice calculated fields, logic statements, and date formulas on real business datasets with live validation.
Explore Tableau Basics FreeFrequently Asked Questions
How do you create a calculated field in Tableau?
Right-click a field or the Data pane > Create > Calculated Field, name it, write the formula with [Field] brackets, validate syntax, and drag it to the view. Tableau marks it with an equals icon.
What is the difference between row-level and aggregate calculated fields?
Row-level like [Sales] - [Profit] computes per row. Aggregate like SUM([Sales]) - SUM([Profit]) computes after aggregation. Mixing them without aggregation causes 'Cannot mix aggregate and non-aggregate' errors.
How do MIN and MAX work in Tableau calculations?
MIN([Sales]) and MAX([Sales]) return the minimum and maximum aggregated values for the current view's partitioning, useful for range checks and outlier bounds per product or region.
When should you use CEILING vs FLOOR?
CEILING([Value]) rounds up, FLOOR([Value]) rounds down. Use them to standardise currency or percentage reporting to clean integers when decimals distract.
Why does Tableau show a red syntax error in a calculated field?
Common causes are nesting SUM inside MIN/MAX incorrectly, mismatched brackets, or mixing aggregated and non-aggregated fields. The Calculation Editor highlights the exact token.

Written by
Founder at Topfolio with 6+ years in data & analytics across JPMC, Ultrahuman, and high-growth startups. Sat on hiring panels, reviewed 500+ resumes, and writes practical SQL & data guides.
Related Articles
Tableau LOD Expressions Guide: FIXED, INCLUDE & EXCLUDE
Master Tableau Level of Detail (LOD) expressions. Learn syntax and examples for FIXED, INCLUDE, and EXCLUDE to calculate Percent of Total without filter errors.
Tableau Complete Guide: Master Business Intelligence and Dashboards (2026)
Master Tableau for business intelligence: data connections, visual analytics, calculated fields, LOD expressions, table calculations, and interactive dashboards.
Tableau Connecting Data Sources: Live vs Extract for Analysts
Connect CSV, Excel and databases in Tableau via the Connections pane and choose Live vs Hyper Extract with data source filters.