What is a calculated field in Tableau?
Quick answer
A calculated field is a new field you create in a BI tool by writing a formula from existing fields, such as Profit = Revenue minus Cost, or Margin = SUM(Profit) / SUM(Revenue). It lives in the BI tool, so the source data does not change.
Last updated
Updated · By Robert Breen
Why it matters
Raw data rarely holds the exact number managers ask about. They want margin, growth, average order value or days to close, and those come from combining columns. A calculated field defines the formula once, and every chart that uses it agrees.
Putting the definition in one place matters more than the math. "Margin" calculated three different ways in three spreadsheets is how a leadership meeting turns into a debate about whose number is right.
A worked example
An online store’s data has Revenue and Cost per order line. Revenue for September is $84,000 and cost is $57,960. A calculated field Margin = (SUM([Revenue]) - SUM([Cost])) / SUM([Revenue]) gives (84,000 − 57,960) / 84,000 = 31%.
Writing it as AVG([Revenue] − [Cost]) / [Revenue] instead (a margin per row, then averaged) gives a different answer, because a $5 order counts as much as a $5,000 one. The first version is what finance means by margin.
Often confused with
Row-level vs aggregate calculations
Row-level formulas ([Revenue] − [Cost]) are computed per row, then summed. Aggregate formulas (SUM([Revenue]) / SUM([Orders])) are computed after summing. Ratios almost always need the aggregate form.
Calculated field vs spreadsheet formula
A spreadsheet formula lives in a cell and is copied down. A calculated field is defined once for the whole data source and applies to every chart.
Calculated field vs measure
A calculated field can be either a measure (a margin) or a dimension (IF [Revenue] > 1000 THEN "Large" ELSE "Small" END).
Tips
- Name it the way the business says it ("Gross margin %"), and add a comment in the formula explaining it.
- Test it on a tiny filtered set where you can check the math by hand.
- Use the aggregate form for any ratio or percentage.
Related terms
Learn it in a free lesson
- Dimensions vs Measures in Tableau, With Examples (about 9 minutes)
Questions about it
- What does a BI analyst do?: A BI analyst turns business questions into trusted numbers and dashboards. What the job involves day to day, the skills it needs and how…
Frequently asked questions
- How do I create a calculated field in Tableau?
- In the Data pane, open the drop-down menu (or right-click an empty area) and choose Create Calculated Field. Name it, type the formula and click OK.
- Does a calculated field change my source data?
- No. It exists only in the Tableau workbook.
- Why does my calculated field say "cannot mix aggregate and non-aggregate"?
- The formula combines a summed field with a row-level field. Wrap both parts in an aggregation, such as SUM, or neither.
All business intelligence terms, A to Z · Free business intelligence lessons