Tableau CASE Statement: The Comprehensive Guide for 2024


Tableau CASE Statement | Hevo Data

Businesses across the world are trying to find some meaning from their vast collections of messy and complicated data. This however is not a straightforward task as the data is present in varying formats and valuable patterns are hard to find. As a result, companies are relying on Business Intelligence (BI) tools like Tableau to sail through their enormous datasets with ease. Moreover, Tableau helps businesses in analyzing and comprehensively visualizing their data. The Tableau platform also offers numerous Logical Functions that users can deploy to customize their Data Management. One such Logical Function is the Tableau CASE Statement

The Tableau CASE Statement operates in a way similar to the IF ELSE statement. The Tableau CASE Statement is designed to evaluate a sequence of interlinked conditional expressions and choose an output based on the given conditions. However, new users face difficulty in understanding the implementation of CASE syntax.

This blog will introduce you to Tableau and list its unique features. It will also elaborate on the importance of Logical Functions and will provide the syntax and examples of some popular case statement Tableau Logical Functions. Furthermore, the article will provide you with a step-by-step approach to setting up and deploying Tableau CASE Statements. Read along to learn more about Tableau’s functionalities and try them out today!

Table of Contents

What is Tableau?

Tableau is an advanced Business Intelligence tool that provides you with high-level Data Analytics and facilitates data-driven decisions. It enables you to extract valuable insights from your data and create detailed visualization. This way, it helps you in understanding the impact of your Product and Marketing Campaigns in a more comprehensive manner. Tableau’s dynamic features allow businesses to customize their user management and gain beneficial results. The simplicity of Tableau is the main reason behind its popularity. Furthermore, its user interface simplifies your task of organizing, managing, visualizing, and understanding data.

Tableau assists you in getting a strong grasp of data. Moreover, you can leverage its Filters to convert the data into a more readable and organized form. It also supports connections with all databases and provides you with a simple drag and drop approach to creating visualizations. Tableau was developed as a self-service analytics platform to allow anyone to easily implement this tool regardless of their skill level.

Key Features of Tableau

  • Data Source Integrations: Tableau offers you plenty of data sources to connect and fetch the required data. Using this tool you can connect to On-premise files, external spreadsheets, relational & non-relational databases, Cloud-based Data Warehouses, and much more. Tableau also allows you to extract data from multiple sources and merge it to generate a combinational visual output.
  • Rich Visualizations: Tableau supports a rich collection of visualizations ranging from basic bar charts & pie charts to complex histograms, Gantt Charts, Treemaps, etc. This way, you can choose from the multitude of visualization options to represent your data to different business teams.
  • High Data Privacy: Tableau ensures high security for your sensitive data. It undertakes all precautions necessary for maintaining your data’s privacy. Tableau implements authentication and permission measures along with row-level filtering to prevent your data from going into the wrong hands. Furthermore, it also permits you to utilize other security protocols such as Active Directory, Kerberos, etc.
  • Mobile View: Tableau is also compatible with mobile devices. Using the Tableau mobile software, you can easily build reports & dashboards and share them with a single click. Tableau also allows you to customize its outlook to suit your mobile screen. This way you can experience a great deal of flexibility and convenience when managing data.
Simplify your Data Analysis with Hevo’s No-code Data Pipeline

Hevo Data, an Automated No-code Data Pipeline helps to Load Data from any data source such as Databases, SaaS applications, Cloud Storage, SDK,s, and Streaming Services and simplifies the ETL process. It supports 150+ data sources like Tableau and loads the data onto Data Warehouses of your choice. Hevo enriches the data and transforms it into an analysis-ready form without writing a single line of code.

Its completely automated pipeline offers data to be delivered in real-time without any loss from source to destination. Its fault-tolerant and scalable architecture ensure that the data is handled in a secure, consistent manner with zero data loss and supports different forms of data. The solutions provided are consistent and work with different Business Intelligence (BI) tools as well.

Get Started with Hevo for Free

Check out why Hevo is the Best:

  • Secure: Hevo has a fault-tolerant architecture that ensures that the data is handled in a secure, consistent manner with zero data loss.
  • Schema Management: Hevo takes away the tedious task of schema management & automatically detects the schema of incoming data and maps it to the destination schema.
  • Minimal Learning: Hevo, with its simple and interactive UI, is extremely simple for new customers to work on and perform operations.
  • Hevo Is Built To Scale: As the number of sources and the volume of your data grows, Hevo scales horizontally, handling millions of records per minute with very little latency.
  • Incremental Data Load: Hevo allows the transfer of data that has been modified in real-time. This ensures efficient utilization of bandwidth on both ends.
  • Live Support: The Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.
  • Live Monitoring: Hevo allows you to monitor the data flow and check where your data is at a particular point in time.
Load Data to BigQuery for Free

Importance of Logical Functions in Tableau

Tableau relies on Logical Functions to check whether a specific conditional equation is true or false (according to boolean logic). For instance, if you wish to check that the sales from each country in which your merchandise is sold, were more or less than a certain threshold value. You can use the following logical function to check your sales performance:

SUM(Sales) > 5,000,000

If the output is True, then your sales are above th set goal(threshold of 5000000), else your sales are not up to the mark and you need to implement certain strategical changes.

Now, Tableau uses numerous in-built logical functions, out of which some of the key functions are as follows:


The Tableau CASE Statement is useful to implement logical tests by evaluating an expression, comparing it to a value sequence( value1, value2, etc.), and returning a specific result. If the value written inside the CASE expression matches with another value in your code, then CASE provides the corresponding return value as output. However, if no match is found, CASE returns a default expression. 

Tableau CASE Statement is one of the easiest and most useful logical functions. You can use the following syntax to understand this Logical Function better:

CASE <expression> WHEN <value1> THEN <return1> WHEN <value2> THEN <return2> ... ELSE <default return> END

The below example shows the implementation of the Tableau CASE Statement’s syntax:

CASE [Region] WHEN 'North' THEN 1 WHEN 'South' THEN 2 ELSE 3 END

2) END

The END Logical Function is useful for testing a series of expressions and returning the value pointed by <then> for the first true <expr>.  The following syntax is required to implement the END function:

IF <expr> THEN <then> [ELSEIF <expr2> THEN <then2>...] [ELSE <else>] END

Similar to its name, the function must be positioned at the end of an expression. The following example showcases the use of END’s syntax:

IF [Profit] > 0 THEN 'Profitable' ELSEIF [Profit] = 0 THEN 'Breakeven' ELSE 'Loss' END


Similar to the above-discussed END function THEN is also used for testing a series of expressions the value pointed by <then> for the first true <expr>. However, unlike END, THEN is placed in the start and middle of the expression using the following syntax:

IF <expre> THEN <then> [ELSEIF ,expr2> THEN <then2>...] [ELSE <else>] END

The following example will showcase how you can implement the THEN statement:

IF [Profit] > 0 THEN 'Profitable' ELSEIF [Profit] = 0 THEN 'Break even' ELSE 'unprofitable' END

The WHEN function operates in a slightly different manner than THEN. It seeks the first <value> that matches <expr> expression and then returns the corresponding <return> value. WHEN relies on the following syntax:

CASE <expr> WHEN <Value1> THEN <return1> ... [ELSE <else>] END

You can understand it better with the following example:


4) AND & OR

The AND function is useful for performing logical conjunction on any 2 expressions using the following syntax:

IF <expr1> AND <expr2> THEN <then> END

The following example will help you understand the working of AND:

IF (ATTR([Country]) = "Brazil" AND SUM([Sales]) < [Fixed Threshold] )THEN "Not Well Performing"

The OR function is complementary to AND is useful to set up a logical disjunction on any 2 expressions. It uses the following syntax:

IF <expr1> OR <expr2> THEN <then> END

The following example will help you understand the working of OR:

IF [Profit] = 0 OR [Profit] < 0 THEN "Needs Urgent Improvement" END

5) IN

The IN function simply compares 2 expressions and returns TRUE if any value in the first expression <expr1> matches a value in the second expression <expr2>. IN operates on the following syntax:

<expr1> IN <expr2>

You can place a Set, a list of literals, or even a combined field in these <expr>. The following examples will help you understand the IN function better:

SUM([Price]) IN (2000, 25, 500)

6) IF & IFF

The IF function is used with THEN and END to test a series of expressions returning the value pointed by <then> for the first true <expr>. It works using the following syntax:

IF <expr> THEN <then> [ELSEIF <expr2> THEN <then2>...] [ELSE <else>] END

The below example will help you understand it better:

IF [Profit] > 0 THEN 'Profitable' ELSEIF [Profit] = 0 THEN 'Breakeven' ELSE 'Loss' END

IFF, on the other hand, checks if a condition is satisfied, and then returns a specific value if TRUE, and another value if FALSE. Moreover, you can also return a third value using the IFF function, if there is no way to determine the condition’s fulfillment or the condition is NULL. You can use the below syntax to implement the IFF function:

IFF(test, then, else, [unknown])

The below example showcases the use of IFF:

IFF([Loss] > 0, 'Loss', 'Profit')

Syntax & Applications of the Tableau CASE Statement

Implementing a Tableau CASE Statement requires the right kind of parameters and fields. Parameters are important if you need to provide interactivity and flexibility to your report, or if you wish to experiment with certain what-if scenarios. Moreover, using these Parameters and Fields, you can enable users to customize their data view.

The following steps will help you in setting up a Tableau CASE Statement:

Step 1: Create New Parameters for Tableau CASE Statement

In Tableau’s Data Pane, navigate to the top right corner and select the drop-down. In the menu, click on “Create Parameter”.

Once you are in the Create Parameter dialog box, execute the below steps:

  • Provide the Parameter a suitable name so that users can understand its functioning. This blog will use the name Select Column 1 Heading.
  • Select a Data Type for your Parameter. Here, it will be String.
  • For Allowable Values, choose List and enter None as the first value of the list. Click Enter.
  • Now, fill the additional dimension fields in your list. Keep in mind that these fields will be explored using your Parameter. 

This blog’s additional fields include customer name, customer segment, region, department, and category fields. These dimensions all belong to the String Data Type. The blow images show your final Parameter values.

Tableau category fields
Image Source
  • Press OK and return to the Calculated Field section.

Now, repeat the above steps and create 3 more Parameters namely, Select Column 2 Heading, Select Row 1 Heading and Select Row 2 Heading. While creating these 3 parameters, instead of entering each value manually, simply click on Add values from > Parameters and add the required values from the above created Select Column 1 Heading.

Step 2: Create New and Calculated Fields for Tableau CASE Statement

Once your parameters for the Tableau CASE Statement are in place, you must now build calculated Data Fields. Go to the Tableau Data Pane and navigate to the top right corner’s drop-down arrow. In the menu that will open, choose Create Calculated Field.

Now, for the Calculated Field dialog box, enter Column 1 Category in the Name field. Next, for Formula, write the following calculations:

CASE [Select Column 1 Heading]
WHEN 'Customer Name' THEN [Customer Name]
WHEN 'Customer Segment' THEN [Customer Segment]
WHEN 'Region' THEN [Region]
WHEN 'Department' THEN [Department]
WHEN 'Category' THEN [Category]

This is also shown in the below image.

Tableau case statement
Image Source

When the status message shows that your formula is valid, press OK.

Similarly, create 3 more calculated fields so that each of your 4 parameters gets 1 Field each. After this, your Parameter-Field pairs will look like the following:

  • Select Column 2 Heading Column 2 Category
  • Select Row 1 Heading Row 1 Category
  • Select Row 2 Heading Row 2 Category

The underlying formula for each calculated field will be the same, except that you will reference a different parameter for each Tableau CASE Statement.

Step 3: Set Up Interactions between Users and Views for Tableau CASE Statement

In this final step to set up the Tableau CASE Statement, share the control of parameters so that users can choose the categories which they wish to display. Therefore, for each of your Parameter, execute the following steps:

  • Go to the Parameters heading and right-click on a parameter as shown in the below image. Then, choose the Show Parameter Control option.
Tableau parameter check
Image Source
  • Go to the Tableau Data Pane and drag the previously created Calculated Fields and drop it on the shelves of Columns and Rows.
  • Next, go to the Tableau Data Pane and drag a measure and drop it into your view. For this blog, Sales is dragged to Label on the Marks card.
  • Now, test your Parameters by choosing Fields from the parameter controls.

The result of the above steps is shown in the below image:

Tableau Calculated Fields
Image Source

Next, Reset all 4 parameters to None. Afterward, publish the resulting workbook to the Tableau Server as shown in the image below.

Tableau Server workflow

Now, users can set up their reports, save the parameter settings, and even share views.

That’s it! Go and try using the Tableau CASE Statement by yourself.


This article introduced you to Tableau and discussed its key features. It also explained the various major logical functions that Tableau provides along with their syntax and examples. Furthermore, the article explained the steps that you can use to implement a Tableau CASE Statement. After reading this article, you can go and experiment with the Tableau CASE Statement and the other Logical functions seamlessly.

Visit our Website to Explore Hevo

A tableau is a great tool for performing Data Analytics and Visualization for your business data. However, at times, you need to transfer data from Tableau and other multiple sources to a Data Warehouse for analysis. Building an in-house solution for this process could be an expensive and time-consuming task. Hevo Data, on the other hand, offers a No-code Data Pipeline that can automate your data transfer process, hence allowing you to focus on other aspects of your business like Analytics, Customer Management, etc.

This platform allows you to transfer data from 150+ data sources like Tableau to Cloud-based Data Warehouses like Snowflake, Google BigQuery, Amazon Redshift, etc. It will provide you with a hassle-free experience and make your work life much easier.

Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand. 

Share your views on connecting Tableau CASE Statement in the comments section!

Abhinav Chola
Research Analyst, Hevo Data

Abhinav is a data science enthusiast who loves data analysis and writing technical content. He has authored numerous articles covering a wide array of subjects in data integration and infrastructure.

No Code Data Pipeline For Your Data Warehouse