Does Not Equal Sign in Tableau?

Cody Schneider7 min read

When you're building a visualization in Tableau, you're often as interested in what to exclude as you are in what to include. To do this, you need a "not equal to" operator, but you'll quickly notice Tableau gives you two options: != and <>,. This article explains the difference between these operators, how to use them effectively in calculated fields and filters, and provides practical examples to help you create more precise and insightful dashboards.

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

"Not Equal To" in Tableau: != vs. <>,

Let's clear this up right from the start: in the context of Tableau's calculation language, there is no functional difference between != and <>. Both operators perform the exact same task, which is to return TRUE if two values are not equal and FALSE if they are.

So, why do both exist? The reason is largely historical and related to their origins in different programming and database languages:

  • <>, is the traditional "not equal to" operator in SQL (Structured Query Language), the standard language for querying databases. Since Tableau often connects directly to SQL databases, it supports this syntax for consistency.
  • != is a more common "not equal to" operator in C-based programming languages like C++, Java, and Python. Many analysts and developers are more familiar with this syntax.

Tableau supports both to be user-friendly for people coming from different technical backgrounds. You won't get a different result or better performance by choosing one over the other.

Which one should you use?

A simple rule of thumb is to pick one and be consistent. If you work on a team, it's a good practice to agree on a standard. Consistency makes your calculated fields easier for everyone to read and maintain. For the rest of this tutorial, we will use !=, but you can always substitute <>, in its place.

Using the "Not Equal To" Operator in Tableau

The "not equal to" operator is most commonly used in two places: Calculated Fields and Filters. These tools allow you to add new logic to your analysis and trim down your data to only what's necessary.

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.

1. In Calculated Fields

Calculated Fields are one of the most powerful features in Tableau. You use them to create new data from your existing data source. The "not equal to" operator is perfect for creating conditional calculations.

Example: Calculating Sales for All Regions Except One

Imagine your company has launched a special focus initiative in the 'West' region, and you want to create a report that shows total sales for all other regions to measure the baseline performance. You can do this by creating a calculated field that makes the 'Sales' value null for the 'West' region.

Step-by-step instructions:

  1. In your Tableau worksheet, right-click on an empty space in the Data pane (the left-hand sidebar) and select "Create Calculated Field...".
  2. Give your calculated field a clear name, like "Sales (Excluding West)".
  3. In the formula box, type the following calculation:
IF [Region] != 'West'
THEN [Sales]
END

Let's break down what this formula does:

  • IF [Region] != 'West': This line checks each row of your data. If the value in the 'Region' dimension is anything other than 'West', the condition is TRUE.
  • THEN [Sales]: If the condition is TRUE, Tableau returns the value from the 'Sales' measure for that row.
  • END: This closes the IF statement. If the initial condition is FALSE (meaning the region is 'West'), the formula implicitly returns a NULL value.

After clicking "OK", you'll see your new measure in the Data pane. You can now drag "Sales (Excluding West)" onto your view instead of the original "Sales" measure to see a chart that automatically excludes the West region.

2. In Filters

Sometimes, you don't need a new calculated field, you just want to completely remove certain data from your worksheet's view. This is a job for the Filters shelf.

Example: Filtering Out a Specific Shipping Mode

Let's say you want to analyze the profitability of different product categories but need to exclude all orders shipped via 'Same Day' delivery because its costs are part of a separate analysis. You can use a conditional filter to accomplish this.

Step-by-step instructions:

  1. Drag the dimension you want to filter by, in this case "Ship Mode", onto the Filters shelf.
  2. A filter dialog box will appear. Select the "Condition" tab at the top.
  3. Under "By formula", enter the following:
[Ship Mode] != 'Same Day'

This tells Tableau to only keep rows where the "Ship Mode" field is not 'Same Day'.

After you click "OK", your entire view — all measures and dimensions — will be filtered to exclude any data associated with 'Same Day' shipments. This is often faster and cleaner than creating brand-new calculated fields for simple exclusions.

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

Combining Not Equal With Other Functions

The real analytical power comes from combining the "not equal to" operator with other logical functions like AND and OR to create more sophisticated rules.

Using != with AND

The AND operator requires that all conditions must be true.

Let's say you want to see sales for a very specific segment: customers in the 'Corporate' segment who are not located in California.

You could create a calculated field named "Corporate Sales (non-CA)" with this formula:

IF [Segment] = 'Corporate' AND [State] != 'California'
THEN [Sales]
END

This will only return a 'Sales' value for rows that meet both conditions simultaneously.

Using != with OR

The OR operator requires that at least one of the conditions is true.

Imagine you want to flag orders that need special review. These might be orders with a 'Low' priority or any order that was not profitable.

You can create a boolean (true/false) calculated field called "Needs a Review?" like this:

[Priority] = 'Low' OR [Profit] <= 0

What if we used != here?

Let's find orders that are high priority or NOT shipped via standard class.

[Priority] = 'High' OR [Ship Mode] != 'Standard Class'

This calculation will return TRUE for any order that's 'High' priority or for any order shipped via First Class, Second Class, or Same Day, regardless of its priority.

Common Mistakes & Best Practices

Using the "not equal to" operator is straightforward, but there are a couple of common pitfalls to be aware of.

1. Case Sensitivity

String comparisons in Tableau are case-sensitive by default. This means Tableau considers 'Texas' and 'texas' to be two different values. A formula like [State] != 'texas' would still include records where the state is 'Texas' (with a capital T).

To avoid this, you can force your strings to be all upper or all lower case within the calculation:

UPPER([State]) != 'TEXAS'

This formula first converts the state value to uppercase and then compares it to 'TEXAS', ensuring the comparison is always accurate regardless of the original capitalization.

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.

2. Dealing with NULLs

A frequent source of confusion is how Tableau handles NULL values. A NULL signifies the absence of a value, so it isn't equal to anything — and it also isn't not equal to anything. A comparison like 'Texas' != NULL doesn't evaluate to TRUE, it evaluates to UNKNOWN.

This means if you have a formula like [Segment] != 'Corporate', any rows where the 'Segment' field is NULL will be excluded from the TRUE results.

If you need to include rows with NULL values in your result, you must explicitly check for them using the ISNULL() function:

[Segment] != 'Corporate' OR ISNULL([Segment])

This formula tells Tableau, "Keep this row if the segment is not 'Corporate' OR if the 'Segment' field has no value at all."

Final Thoughts

The "not equal to" operator, whether you choose to write it as != or <>,, is an essential tool for excluding data and refining the focus of your Tableau analysis. By using it in calculated fields and filters, you can move beyond simple visualizations and start answering more specific, targeted business questions with greater precision.

Mastering tools like Tableau takes time, and figuring out the right syntax is often half the battle. At Graphed, we believe getting insights from your data shouldn't require you to learn a query language or hunt through documentation. Instead of writing formulas like IF [Region] != 'West' THEN [Sales] END, we enable you to use natural language and simply ask, "Show me my sales for all regions except the West." Our platform connects directly to your data sources and builds real-time dashboards for you in seconds, letting you focus on the insights, not the syntax.

Related Articles