How to use a case statement in tableau

This recipe helps you use a case statement in tableau

Recipe Objective:-How to use a case statement in tableau?

Step 1:-

Import any data set in the data source. For example, here, the "Global Superstore" data set excel file is imported.

Step 2:-

Drag and drop the orders sheet in the schema pane.

Step 3:-

Go to sheet1; here, different dimensions and measures are available. We have to use the case statement; we will replace the Country name "The United States" with "USA" with the help of the case statement in tableau.

Step 4:-

Go to the Country dimension and click on the drop-down available. Then click on the create-calculated field, a window will appear named Calculation1, by default. We will rename it to "Country abbreviation".

Getting Started with Image Segmentation using Mask R-CNN

Step 5:-

Go to the window below where [Country] is by default is shown. Type Case in front of [Country], we can use the tab button so that the Case statement appears.

Step 6:-

After Case [Country], give space and type WHEN "The United States" THEN "USA" ELSE "World" END. Click on Apply and Ok.

Step 7:-

The Statement will appear as:- Case [Country] WHEN "The United States" THEN "USA" ELSE "World" END. It will create a new field named Country abbreviation under the dimensions.

Step 8:-

Now drag and drop the Country abbreviation dimension and Country dimension in the row shelf and similarly drag and drop the sales measure (sum of sales) in the column shelf. It will create a horizontal bar chart in the worksheet canvas.

Step 9:-

The bar chart indicates the Country abbreviation as "USA" and Country as "The United States," for which we applied the Case statement. The rest of the Countries will appear in the "World" shown below, here also Case statement exists. For simplicity, we can see the visualization using a symbol map under the show me tab.

What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Linear Regression Model Project in Python for Beginners Part 1
Machine Learning Linear Regression Project in Python to build a simple linear regression model and master the fundamentals of regression for beginners.

Learn to Build a Siamese Neural Network for Image Similarity
In this Deep Learning Project, you will learn how to build a siamese neural network with Keras and Tensorflow for Image Similarity.

LLM Project to Build and Fine Tune a Large Language Model
In this LLM project for beginners, you will learn to build a knowledge-grounded chatbot using LLM's and learn how to fine tune it.

Multilabel Classification Project for Predicting Shipment Modes
Multilabel Classification Project to build a machine learning model that predicts the appropriate mode of transport for each shipment, using a transport dataset with 2000 unique products. The project explores and compares four different approaches to multilabel classification, including naive independent models, classifier chains, natively multilabel models, and multilabel to multiclass approaches.

Create Your First Chatbot with RASA NLU Model and Python
Learn the basic aspects of chatbot development and open source conversational AI RASA to create a simple AI powered chatbot on your own.

Time Series Python Project using Greykite and Neural Prophet
In this time series project, you will forecast Walmart sales over time using the powerful, fast, and flexible time series forecasting library Greykite that helps automate time series problems.

Loan Eligibility Prediction in Python using H2O.ai
In this loan prediction project you will build predictive models in Python using H2O.ai to predict if an applicant is able to repay the loan or not.

Langchain Project for Customer Support App in Python
In this LLM Project, you will learn how to enhance customer support interactions through Large Language Models (LLMs), enabling intelligent, context-aware responses. This Langchain project aims to seamlessly integrate LLM technology with databases, PDF knowledge bases, and audio processing agents to create a comprehensive customer support application.

NLP Project for Multi Class Text Classification using BERT Model
In this NLP Project, you will learn how to build a multi-class text classification model using using the pre-trained BERT model.