How to Create Metrics in Tableau

Cody Schneider8 min read

Creating your first chart in Tableau is a great start, but the real power comes from moving beyond the default data fields to create your own custom metrics. By building your own calculations and interactive elements, you can answer highly specific questions about your business that standard fields can’t address. This article will guide you through the process, covering how to create calculated fields, add interactivity with parameters, and tackle complex questions using Level of Detail expressions.

What Are Custom Metrics in Tableau?

In Tableau, "measures" are the numbers you want to analyze - think Sales, Profit, or Website Sessions. Out-of-the-box, these are fantastic for big-picture analysis. But what if you want to know your Profit Ratio, which isn't a default field in your data? Or maybe you want to see how performance stacks up against a sales goal that changes every month.

This is where custom metrics come in. They are new fields you create within Tableau using formulas, logic, and user-defined values to extend your analysis. There are three primary ways to build them:

  • Calculated Fields: The most common method, using formulas to create new measures or dimensions from your existing data.
  • Parameters: User-driven inputs that add a layer of interactivity to your dashboards, allowing viewers to change values and see the visualization update in real time.
  • Level of Detail (LOD) Expressions: More advanced calculations that let you compute values at a different level of granularity than what’s shown in your view.

Let's walk through how to create each one, starting with the foundation: calculated fields.

The Foundation: Creating Calculated Fields

Calculated fields are the workhorses of custom analytics in Tableau. They allow you to combine, segment, and transform your data to uncover deeper insights. You can perform simple arithmetic, like calculating a profit margin, or use complex logical statements to group data into new categories.

Step-by-Step: Your First Calculated Field

Let's create a very common and useful metric: Profit Ratio. This metric isn't typically included in raw sales data but is easy to calculate if you have Sales and Profit figures.

  1. Open the Calculation Editor: With your Tableau workbook open, navigate to the Data pane on the left side of the screen. Right-click anywhere in the blank space below your fields and select Create Calculated Field. Alternatively, you can click the small downward arrow at the top of the Data pane and choose the same option.
  2. Name Your Metric: The calculation editor window will pop up. The first step is to give your new metric a clear and descriptive name. Let’s call this one "Profit Ratio."
  3. Write the Formula: In the large text box, you'll write the formula. To calculate the profit ratio, we need to divide the total profit by the total sales. Tableau uses aggregation functions like SUM(), AVG(), MIN(), and MAX() to compute measures. For a ratio like this, we want to sum all profits and divide by the sum of all sales.

The formula is:

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

As you type, Tableau will suggest field names, which you can click to add to your formula. This helps avoid typos. Once you’re done, look at the bottom of the editor. It should say, "The calculation is valid." If there's an error, Tableau will provide a hint about what's wrong.

  1. Save Your New Metric: Click OK. You'll now see "Profit Ratio" in your Data pane under the Measures section, complete with an equals sign (=) next to the icon to show it's a calculated field.
  2. Use Your Metric: Now you can use this new metric just like any other field. Drag "Product Category" to Rows and drag your new "Profit Ratio" to Columns to see which categories are the most profitable. You can even change its default number format by right-clicking it in the Data pane, navigating to Default Properties > Number Format..., and selecting "Percentage."

Getting More Tactical with Logic (IF/THEN/ELSE)

Calculations aren’t just for math. You can also use them to create new dimensions to categorize or segment your data. Logical functions like IF, THEN, ELSEIF, and ELSE are perfect for this.

Example: Creating Profitability Tiers

Imagine you want to quickly see which sales are highly profitable, breaking even, or unprofitable. You can create a calculated field that automatically assigns a category to each order based on its profit.

  1. Open the editor and name your new field "Order Profitability."
  2. Write the following logical statement:
IF SUM([Profit]) > 500 THEN "High Profit"
ELSEIF SUM([Profit]) > 0 THEN "Low Profit"
ELSE "Unprofitable"
END
  1. Click OK to save it. This field will appear in the Dimensions pane because it produces string values ("High Profit," etc.), not numbers.

Now, you can use this new dimension to color-code your charts. For instance, create a bar chart showing Sales by Sub-Category, then drag "Order Profitability" to the Color shelf. Instantly, you’ll see which sub-categories are driving profit and which ones are losing money. This is much faster and more intuitive than trying to interpret raw profit numbers one line item at a time.

Adding Interactivity with Parameters

Parameters take your dashboards from static reports to interactive tools. A parameter is a workbook variable, like a number, date, or string, that can be used to replace a constant value in a calculation, filter, or reference line. This gives the end-user control over what they see without needing to edit the worksheet themselves.

Step-by-Step: Creating a Dynamic Sales Goal

Let's build a parameter that lets a user set a sales goal and then create a metric that calculates performance against that goal.

  1. Create the Parameter: In the Data pane, right-click and select Create Parameter.
  • Give it a name, like "Sales Target."
  • Set the Data type to Integer.
  • Set the Current value to a reasonable starting point, like 500,000.
  • For Allowable values, choose Range. Set a minimum of 100,000, a maximum of 1,000,000, and a step size of 50,000. This will create a slider for the user.

Click OK.

  1. Make the Parameter Work: On its own, a parameter does nothing. You have to link it to your data using a calculated field.
  • Create a new calculated field called "Performance Against Target."
  • The formula will use our Sales measure and subtract the parameter:
SUM([Sales]) - [Sales Target]
  • Notice the parameter [Sales Target] is a different color in the formula editor. Click OK.
  1. Bring it all to Life:
  • Go to a worksheet and add a visualization, like a single large number showing the "Performance Against Target" metric.
  • Find your "Sales Target" parameter in the Data pane (it will be at the bottom). Right-click it and select Show Parameter.
  • A slider control will appear in your view. Now, you or your users can drag the slider, and the "Performance Against Target" value will update in real time.

This adds a huge amount of value, transforming a static report into a "what-if" analysis tool.

Advanced Analysis: Level of Detail (LOD) Expressions

LOD expressions are for when you need to answer questions that involve multiple levels of granularity in one view. For example, "What is the average sales for each customer, and how does each individual order compare to that average?" To answer this, you need to calculate the average customer sales at the customer level, but compare it against data at the individual order level.

There are three types of LOD expressions: FIXED, INCLUDE, and EXCLUDE. We'll focus on FIXED, as it's the most common and arguably the most powerful.

Example: Finding the First Purchase Date for Each Customer

A classic use for a FIXED LOD is finding when each customer made their first purchase. This can be used to analyze customer cohorts.

  1. Create the FIXED LOD Calculated Field:
  • Open the calculation editor and name it "Customer First Purchase Date."
  • The syntax for LODs is a bit different. It uses curly braces {}.
  • Write the formula:
{ FIXED [Customer Name] : MIN([Order Date]) }
  1. Understand What It Does: This calculation tells Tableau: "For every unique Customer Name in the entire dataset, find the minimum Order Date and store that date." The result is a new field where every row of data associated with that customer contains their single, very first purchase date.
  2. Use the Calculation: Now, you can create a chart showing the number of new customers over time. Drag this new "Customer First Purchase Date" to Columns (set it to MONTH), and drag "Customer Name" to Rows (set the aggregation to Count Distinct). This will show you exactly how many new customers you acquired each month, an analysis that would be very difficult without an LOD expression.

LOD expressions are a bit of a mental hurdle at first, but mastering them opens up an entirely new level of analytical depth in Tableau.

Final Thoughts

Creating your own metrics in Tableau is the key to unlocking unique, valuable insights tailored to your business questions. By mastering calculated fields for custom formulas, using parameters to build interactive dashboards, and leveraging LOD expressions for complex analysis, you can move from a data viewer to a true data analyst.

But while Tableau is extremely powerful, getting comfortable with writing formulas and understanding complex concepts like LODs has a legitimate learning curve. At Graphed , we’ve focused on removing that friction. Instead of writing formulas, you can connect your data sources - like Shopify, Google Analytics, or Salesforce - and simply ask questions in plain English. For example, you can tell Graphed, “Create a dashboard showing profit ratio by product category for last quarter,” and our AI analyst builds the live dashboard for you instantly, without you ever having to open a calculation editor.

Related Articles

How to Connect Facebook to Google Data Studio: The Complete Guide for 2026

Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.

Appsflyer vs Mixpanel​: Complete 2026 Comparison Guide

The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.