How to Create a Measure in Tableau

Cody Schneider••7 min read

Creating custom calculations is the first step toward getting real insights from your data in Tableau. This article will show you exactly how to create a measure using Tableau’s calculated fields, providing clear steps and practical examples you can use right away.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

What Exactly is a Measure in Tableau?

In Tableau, your data is divided into two main types: dimensions and measures. Understanding the difference is fundamental to using the tool effectively.

  • Dimensions: These are qualitative, descriptive fields. They are the "who, what, when, and where" of your data. Think of categories like Product Name, Region, Customer Segment, or Order Date. When you drag a dimension into a view, it typically creates labels or headers. In the Data pane, dimensions are usually blue.
  • Measures: These are your numbers - quantitative, numeric fields that you can perform calculations on. Measures are the "how much" and "how many." Examples include Sales, Profit, Quantity, or Ad Spend. When you drag a measure into a view, Tableau automatically aggregates it using a function like SUM, AVG, or COUNT. In the Data pane and on your shelves, measures are typically green.

Simply put, dimensions segment your data, while measures are the values you analyze within those segments. Creating custom measures allows you to go beyond the raw numbers and calculate key performance indicators (KPIs) like profit margins, conversion rates, and growth percentages that are specific to your business goals.

How to Create a Measure with a Calculated Field

The primary way to create a new measure in Tableau is by using a Calculated Field. This powerful feature lets you write formulas to derive new data from your existing fields. It works a lot like writing formulas in a spreadsheet, but with a bit more structure.

Let's walk through creating a common and essential metric: Profit Ratio.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Step-by-Step Guide:

1. Open the Calculated Field Editor

In the Data pane sidebar, right-click anywhere on an empty space (or on an existing field) and select Create Calculated Field…. You can also click the small downward arrow at the top of the Data pane and choose the same option.

2. Name Your New Measure

The editor window will appear. The first thing you should always do is give your calculation a clear, descriptive name. In this case, type "Profit Ratio" into the title box at the top.

3. Write the Formula

In the main empty box, you will write the formula that defines your measure. For Profit Ratio, the formula is profit divided by sales. Tableau automatically aggregates measures when you use them, so it's best practice to specify the aggregation within your formula.

Type the following formula:

SUM([Profit]) / SUM([Sales])

Let's break down this formula:

  • SUM(): This is the aggregation function. We're telling Tableau to sum up all the values in the specified field before performing the division.
  • [Profit] and [Sales]: The square brackets indicate that these are existing fields in your data source. As you type, Tableau will suggest available fields, which you can click to autofill, helping to avoid typos.
  • /: This is the division operator.

4. Validate the Calculation

At the bottom of the editor, there's a small message. If you've typed everything correctly, it will say, "The calculation is valid." If there's an error, it will turn red and provide a hint about what's wrong.

5. Click "OK"

Once your calculation is valid, click the "OK" button. Your new measure, "Profit Ratio," will now appear in the Data pane under the Measures section, usually marked with an equals sign (=) next to the data type icon (e.g., =#).

Advanced Examples for Common Business Scenarios

Now that you know the basics, let's apply them to a few more practical examples you're likely to encounter in marketing, sales, or e-commerce analysis.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Example 1: Calculating Cost Per Acquisition (CPA)

Imagine you have data from your ad platforms with fields for Total Ad Spend and Conversions. CPA is a critical marketing metric that tells you how much you pay for each new customer or lead.

  • Name: CPA
  • Formula: SUM([Total Ad Spend]) / SUM([Conversions])

After creating this measure, you’ll probably want to format it as currency. To do this, right-click your new "CPA" measure in the Data pane, go to Default Properties > Number Format…, and select Currency (Standard).

Example 2: Calculating Average Order Value (AOV)

For an e-commerce dashboard, AOV is an essential metric. It's calculated by dividing total revenue by the total number of orders. Sometimes you don't have a "Number of Orders" field directly, but you do have an Order ID for every line item. You can use a COUNTD (Count Distinct) aggregation to solve this.

  • Name: Average Order Value
  • Formula: SUM([Sales]) / COUNTD([Order ID])

Here, COUNTD([Order ID]) counts the number of unique order IDs, giving you the correct total number of orders even if your data has multiple rows for a single order (e.g., for different products).

Example 3: Creating a Simple Year-over-Year (YoY) Growth Calculation

Calculating period-over-period growth is a powerful way to measure performance trends. This usually requires a few calculated fields to accomplish.

Step 1: Isolate This Year's Sales

  • Name: This Year Sales
  • Formula:
IF YEAR([Order Date]) = YEAR({MAX([Order Date])})
THEN [Sales]
END

This formula uses an LOD (Level of Detail) expression {MAX([Order Date])} to find the most recent year in your entire dataset. It then checks if the year of the Order Date for each row matches that most recent year and, if it does, returns the sales amount.

Step 2: Isolate Last Year's Sales

  • Name: Last Year Sales
  • Formula:
IF YEAR([Order Date]) = YEAR({MAX([Order Date])}) - 1
THEN [Sales]
END

This is almost identical but uses - 1 to get the data for the year prior to the most recent year in your data.

Step 3: Calculate the YoY Growth Rate

Now that you have both sales periods as separate measures, you can calculate the growth rate.

  • Name: YoY Sales Growth %
  • Formula:

(SUM([This Year Sales]) - SUM([Last Year Sales])) / SUM([Last Year Sales])

After creating this measure, use the Default Properties > Number Format… option to set its format to Percentage.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Tips for Working with Measures

Keep these tips in mind to make your workflow smoother and your calculations more robust.

  • Use Comments: As your formulas get more complex, it helps to leave notes for yourself or your team. You can add a comment by starting a line with two slashes //. For example: // This calculates profit ratio as a percentage.
  • Convert Dimensions to Measures: Sometimes, a field like an ID number is imported as a number but Tableau treats it as a dimension because it’s a discrete identifier. If you need to perform a calculation on it (like a count), you can right-click the field in the Data pane and select Convert to Measure.
  • Drag and Drop Fields: Instead of typing field names into the formula editor, you can drag them directly from the Data pane and drop them into the editor. This ensures you're using the correct field name and speeds up the process.
  • Change Default Aggregation: Tableau defaults to SUM for most measures. If you find you’re always changing a field's aggregation to AVG or COUNT in your views, you can change its default. Right-click the measure, go to Default Properties > Aggregation, and pick your preferred one.

Final Thoughts

Creating measures with calculated fields transforms Tableau from a simple chart-maker into a powerful analysis tool. By defining your own KPIs and metrics, you can start answering the specific business questions that matter most to you and move from raw data to actionable insights.

The learning curve for tools like Tableau, especially its more advanced calculations, is a real challenge for many teams who just want a quick answer. That's a big reason we built Graphed. Instead of creating multiple calculated fields and wrestling with formulas in an editor, you can just ask in plain English: "Show me my year-over-year sales growth as a line chart." Our system creates the report and performs the calculations instantly, connecting directly to your live data to give you the clarity you need in seconds, not hours.

Related Articles