How to Filter Using Tableau Calculation

Cody Schneider••9 min read

Using a standard filter in Tableau is simple enough for basic tasks, but what happens when you need to filter your view based on a specific, multi-step condition or let an end-user control the data with more than just a simple drop-down? This is where calculated fields come into play, instantly elevating your dashboard from a static report to a dynamic analysis tool. This article will show you exactly how to create and use calculated fields for filtering, unlock advanced filtering capabilities, and give you practical examples you can use immediately.

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

Why Use a Calculated Field to Filter at All?

You can drag almost any dimension or measure to the Filters shelf and cut your data down, so why add the extra step of writing a calculation? The short answer is flexibility and power. While standard filters are great for simple breakouts like isolating a specific region or a range of dates, calculated fields let you define precise and often complex rules for what data should be included or excluded.

Here are a few scenarios where a calculated field filter is not just helpful, but necessary:

  • Complex Conditional Logic: You want to show sales associates who either surpassed $10,000 in sales or closed more than 15 deals. A standard filter struggles here, but an IF statement in a calculated field handles it perfectly.
  • Dynamic Filtering with Parameters: Instead of pre-setting a filter, you can let the user input a value (like a sales target) and use a calculation to filter the view based on their input. This is the foundation of interactive dashboarding.
  • Filtering on an Aggregate Level: You need to show only the product sub-categories whose total sales exceed a certain threshold. A standard filter works on the row-level data before it's aggregated, whereas a calculated field can filter based on the sum, average, or count within the view.
  • Relative Date Filtering with Specific Rules: Building a filter for "Last 30 Days" is easy. But what about the "Last 30 Weekdays"? That custom logic requires a calculation.

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.

The Core Concept: A Simple TRUE/FALSE

At its heart, filtering with a calculated field is incredibly straightforward. The goal is to write a formula that results in one of two outcomes for every mark in your view: TRUE or FALSE.

Think of it as asking a yes-or-no question of your data. For example:

SUM([Sales]) > 20000

If you have a chart showing sales by customer, this calculation will check each customer's total sales. If a customer's total is $25,000, the result is TRUE. If another's is $15,000, the result is FALSE.

Once you have this calculation, you simply drag it onto the Filters shelf and tell Tableau to only keep the marks where the result is TRUE. That’s the entire mechanism. All the data that resulted in a FALSE is hidden from view, giving you a perfectly executed filter based on your custom logic.

How to Create and Use a Calculation as a Filter: Step-by-Step

Let's walk through an actual example using the Sample - Superstore dataset. Our goal is to create a view that only shows us orders that were profitable.

  1. Create a Calculated Field: In the Data pane on the left, right-click and select "Create Calculated Field." Alternatively, you can go to the "Analysis" menu at the top and choose the same option.
  2. Write a Boolean (True/False) Formula: A calculation window will pop up. First, give your calculation a logical name, like "Is Profitable." Then, in the formula box, type the condition that will evaluate to true or false. In our case, the formula is very simple:
[Profit] > 0

This formula checks the Profit value for every single row in the dataset. If it's a positive number, the result is TRUE. If it is zero or negative, the result is FALSE.

  1. Drag the Calculated Field to the Filters Shelf: Once you click "OK," you will see your new "Is Profitable" calculation in the Data pane (it will have an =T|F icon next to it). Drag this onto the Filters shelf card.
  2. Select "True" from the Filter Options: A small dialog box will appear asking you which values you want to keep. It will list "True" and "False." Check the box for "True" and click "OK."

Your visualization will instantly update to show data only from profitable orders. All the rows with negative profit have been filtered out.

Practical Examples of Filter Calculations

The real power comes when you move beyond simple one-line checks. Here are some common business scenarios and the calculated fields that solve them.

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: Isolating Your "High-Impact" Customers

Let's say you want to see which customers are driving your business. You could define a "high-impact" customer as someone who has brought in more than $5,000 in total sales and has placed at least 5 separate orders.

The Calculation:

SUM([Sales]) > 5000 AND COUNTD([Order ID]) >= 5
  • SUM([Sales]) > 5000 handles our aggregate sales threshold.
  • COUNTD([Order ID]) >= 5 performs a distinct count of order IDs to ensure they've shopped multiple times.
  • The AND operator requires both conditions to be TRUE for the entire calculation to be TRUE.

Create a view with Customer Name on Rows and SUM([Sales]) on Columns. Then, drag this calculated field to the Filters shelf and select True. The list will shrink to display only your VIP customers.

Example 2: Filtering on a Date Range but Excluding Weekends

Imagine your Head of Marketing wants a report of website traffic for the last 30 days, but only cares about business days, since weekend traffic is not relevant to their reporting.

The Calculation:

[Your_Date_Field] >= TODAY() - 30
AND DATEPART('weekday', [Your_Date_Field]) > 1
AND DATEPART('weekday', [Your_Date_Field]) < 7
  • [Your_Date_Field] >= TODAY() - 30 sets the 30-day window.
  • DATEPART('weekday', [Your_Date_Field]) returns a number for the day of the week, where 1 is Sunday and 7 is Saturday.
  • Combining the next two lines excludes Sunday (1) and Saturday (7), leaving only the weekdays in your filtered view.

Example 3: Adding Dynamic Filtering with a Parameter

Creating an interactive dashboard is key for self-service analytics. In this example, we'll let a manager choose a Profit Ratio threshold from a parameter control to find underperforming product sub-categories in real-time.

Step A: Create the Parameter

  1. In the Data Pane, right-click and choose "Create Parameter...".
  2. Name it "Profit Ratio Threshold".
  3. Set the Data type to Float.
  4. Set "Display format" to Percentage.
  5. Under "Allowable values," choose Range. Set the Minimum to -1 (for -100%), Maximum to 1 (for 100%), and Step size to 0.1 (for 10% increments).
  6. Click OK. You will see the new parameter at the bottom of the Data pane.

Step B: Create the Calculated Field Filter

Create a new calculated field that references the parameter you just built:

SUM([Profit]) / SUM([Sales]) < [Profit Ratio Threshold]

This calculation gets the profit ratio for each mark in your view (e.g., each sub-category) and then checks if it is less than the value currently selected in the parameter.

Step C: Put it all together

  1. Build a view with Sub-Category on Rows.
  2. Drag this new calculated field to the Filters shelf and set it to True.
  3. Right-click on the "Profit Ratio Threshold" parameter in the Data pane and select "Show Parameter".

Now, you'll have a slider or type-in box on your dashboard. When you move the slider to 10%, the chart will instantly update to show only the sub-categories with a profit ratio below 10%.

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.

Example 4: Search-like Filtering Based on Keywords

Need to find all products related to "desks" or "chairs"? A calculated field with the CONTAINS() function is perfect for this text-based filtering. It offers more flexibility than a wildcard filter when you need to check for multiple, unrelated keywords.

The Calculation:

CONTAINS(UPPER([Product Name]), "DESK") 
OR CONTAINS(UPPER([Product Name]), "CHAIR")
  • CONTAINS([String], [Substring]) returns TRUE if the Substring is found anywhere within the main String.
  • Using UPPER() on the product name makes the search case-insensitive. Just remember to make your search substrings uppercase as well ("DESK", not "desk").
  • The OR tells Tableau to keep any product that contains either keyword.

Tips for Better Filter Calculations

  • Give Calculations a Clear Name: "Calculation 2" tells you nothing when you revisit your workbook in six months. A name like "[FILTER] Top Customers" is far more useful. Using a prefix helps you quickly find your filters in the Data pane.
  • Use Comments in Your Code: You can add comments to your formulas by starting a line with //. Use this to explain the goal of a complex calculation for yourself and for colleagues.
  • Be Aware of Aggregation: Remember the difference between a row-level calculation like [Profit] > 0 and an aggregate calculation like SUM([Profit])/SUM([Sales]) > 0.1. The first is evaluated for every row of your data source, while the second is calculated after the data is grouped together in your visualization (e.g., by customer or by region).

Final Thoughts

Putting calculated fields on the Filters shelf is one of the most effective ways to level up your skills in Tableau. It unlocks an enormous amount of control, allowing you to move from simply displaying data to building an interactive and analytical experience for your users based on your exact business rules.

Even with advanced tools like Tableau, building a report that filters and combines data across multiple platforms still involves hunting down formulas and wrestling with settings. We built Graphed to remove that friction completely. You can connect your data sources - like Google Analytics, Shopify, and Salesforce - and then create detailed dashboards simply by asking for what you need in plain English. Instead of building your "Last 30 Weekdays" filter manually, you just ask, “show me sales for the last 30 weekdays," and our AI builds the report for you instantly, on a live-updating dashboard.

Related Articles