What is the IN Function in Tableau?

Cody Schneider7 min read

Tired of writing long, clunky OR statements in your Tableau calculations? The IN function is the clean, efficient solution you need. It simplifies your formulas by letting you check if a field's value matches any value within a specified list. This article will walk you through exactly what the IN function is, why it's so useful, and how to apply it in your own dashboards with practical, step-by-step examples.

GraphedGraphed

Your AI Data Analyst to Create Live Dashboards

Connect your data sources and let AI build beautiful, real-time dashboards for you in seconds.

Watch Graphed demo video

What is the Tableau IN Function?

The IN function is a logical operator in Tableau that returns a boolean value - either TRUE or FALSE. It tests whether a specified value exists within a comma-separated list, a Tableau Set, or a combined field. Think of it as asking Tableau, "Is the value from this field in this list I've provided?"

It's an elegant way to avoid messy calculations cluttered with multiple OR conditions, making your logic easier to write, read, and debug.

The Basic Syntax

The structure of the IN function is straightforward:

expression IN (value1, value2, ...)
  • expression: This is the field or value you want to check. For example, [Region].
  • (value1, value2, ...): This is the comma-separated list of values you want to check against. For example, ("South", "West").

In a calculated field, it often looks like this:

[Region] IN ("South", "West")

If a record's region is either "South" or "West," this formula will return TRUE. For any other region like "Central" or "East," it will return FALSE.

Why Should You Use the IN Function?

You could technically achieve the same result with a series of OR statements or a long CASE statement, but the IN function offers significant advantages in simplicity, readability, and sometimes even performance.

Free PDF Guide

AI for Data Analysis Crash Course

Learn how to get AI to do data analysis for you — the best tools, prompts, and workflows to go from raw data to insights without writing a single line of code.

It Makes Formulas Cleaner and More Readable

Imagine you want to create a group for all US states on the West Coast. Without the IN function, your calculation would be a cumbersome chain of ORs.

Before (using OR):

[State] = "California" OR
[State] = "Oregon" OR
[State] = "Washington" OR
[State] = "Arizona" OR
[State] = "Nevada"

This is hard to read and even harder to update. If you need to add another state, you have to add another OR clause, which increases the chances of a syntax error.

After (using IN):

[State] IN ("California", "Oregon", "Washington", "Arizona", "Nevada")

This version is far more concise. The intent is immediately clear: you're checking if the state is part of the specified West Coast list. It’s significantly easier to read and maintain.

It Integrates Perfectly with Tableau Sets

One of the most powerful features of the IN function is its seamless compatibility with Tableau Sets. A Set is a custom field that defines a subset of your data. You can create a Set of top customers, specific products, or certain marketing channels. Once you have a Set, you can use it in a calculation. When you check for membership in a Set (e.g., IF [Top Customer Set] THEN...), Tableau is essentially using the IN operator logic under the hood.

It Simplifies Conditional Filtering

The IN function is perfect for building boolean (True/False) calculated fields that you can then drag onto the Filters shelf. This lets you quickly isolate the data you care about without building complicated groups or nested conditions directly in the filter dialog.

GraphedGraphed

Your AI Data Analyst to Create Live Dashboards

Connect your data sources and let AI build beautiful, real-time dashboards for you in seconds.

Watch Graphed demo video

Practical Examples: How to Use the IN Function Step-by-Step

The best way to learn is by doing. Let's walk through a few common scenarios using the Sample - Superstore dataset that comes with Tableau.

Example 1: Create a Calculated Field to Group Specific Categories

In this scenario, we want to group sales into two buckets: "Core Business" (from Technology and Office Supplies) and "Other Business" (everything else).

  1. Create a New Calculated Field: In your Tableau worksheet, right-click anywhere in the Data pane and select "Create Calculated Field."
  2. Name Your Calculation: Give it a descriptive name, like "Business Group."
  3. Write the Formula: Enter the following logic into the calculation editor.
IF [Category] IN ("Technology", "Office Supplies") 
THEN "Core Business" 
ELSE "Other Business" 
END

This formula checks each row's 'Category'. If it's "Technology" or "Office Supplies," it assigns the value "Core Business", otherwise, it assigns "Other Business."

  1. Use the New Field in a View: Click "OK" to save the field. Now, you can use it just like any other dimension. Drag "Business Group" to the Rows shelf and "Sales" to the Columns shelf. You’ll instantly see your sales data segmented into your two new groups.

Example 2: Create a Dynamic TRUE/FALSE Filter

Sometimes you don't need to create a new group. Instead, you just want to filter your view to show a specific subset of data. For example, let's say we only want to see data for sales from our premium Ship Mode options: "First Class" and "Same Day."

  1. Create a Boolean Calculated Field: Open the calculation editor and name your new field "Premium Shipping Filter."
  2. Write the Formula: The formula here is even simpler because we just need a True/False output.
[Ship Mode] IN ("First Class", "Same Day")
  1. Apply the Filter: Click "OK." Drag your new "Premium Shipping Filter" field from the Data pane directly onto the Filters shelf.
  2. Set the Filter: A small dialog box will appear. Check the box for "True" and click "OK."

Your entire dashboard will now update to show data only for orders shipped via "First Class" or "Same Day." This is a clean and reusable way to apply complex filtering rules consistently.

Free PDF Guide

AI for Data Analysis Crash Course

Learn how to get AI to do data analysis for you — the best tools, prompts, and workflows to go from raw data to insights without writing a single line of code.

Example 3: Use the IN Function with a Set

Sets are where the IN concept really shines. Let's create a report that shows total sales for a dynamically-defined group of our favorite sub-categories.

  1. Create a Set: In the Data pane, find the 'Sub-Category' dimension. Right-click on it, then navigate to Create > Set.
  2. Define and Name the Set: In the dialog box, name your set something like "Focus Sub-Categories." In the main area, manually select a few sub-categories you want to track, like "Chairs," "Phones," "Binders," and "Tables." Click "OK."
  3. Create the Calculation: Now, let's use this set in a calculated field. Create a new calculation called "Sales from Focus Sub-Categories."
IF [Focus Sub-Categories] THEN [Sales] END

Wait, where is the IN function? Here's the cool part: when you use a Set as a condition in an IF statement, Tableau implicitly treats it as an IN check. IF [Focus Sub-Categories] is just a shorthand way of saying "if the Sub-Category for this row is IN the Focus Sub-Categories set." This calculation will return the Sales amount if the sub-category is in your set, and NULL otherwise.

  1. Visualize the Result: Drag your "Sales from Focus Sub-Categories" over SUM([Sales]) on the marks card to see just the portion of sales from your favored groups.

Common Mistakes and Pro Tips

The IN function is powerful but, like any tool, has a few quirks to be mindful of.

  • Matching Data Types: The function is strict about data types. If [StoreID] is a number, you cannot check it against a list of strings. [StoreID] IN ("101", "102") will fail. It must be [StoreID] IN (101, 102).
  • Quotation Marks: Remember to wrap string values in quotes (single ' or double " quotes both work). Number and date values should not be in quotes.
  • Handling Case Sensitivity: By default, some databases Tableau connects to might be case-sensitive, while others aren't. "East" is not the same as "east." To avoid issues, you can standardize the case using the UPPER() or LOWER() function.
UPPER([Region]) IN ("EAST", "CENTRAL")

Final Thoughts

The IN function is a fundamental part of writing clean, efficient, and readable calculations in Tableau. Mastering it helps you move beyond messy OR chains, enabling you to build powerful categorizations and filters with ease, especially when combined with the dynamic capabilities of Sets.

Building calculations and fine-tuning dashboards in tools like Tableau is a powerful skill, but it still requires a significant investment of time. We built Graphed because we believe getting insights from your data shouldn't involve writing formulas or manually configuring charts. Instead of learning functions and dragging and dropping pills, you simply connect your data sources and describe what you want to see - like "show me sales for my core business categories." Graphed instantly builds the dashboard for you, turning hours of report building into a 30-second conversation and freeing you up to act on your insights.

Related Articles