Tableau is a rapid-fire business intelligence software that allows you to take decisions at a very fast pace. Tableau is also a leading new generation Business Intelligence (BI) application which is also dubbed as “self-service” data discovery tool as it can be achieved with almost no support from IT staff. This product shines as a graphical tool or a visualization tool, where you would have relied on various other tools and takes longer durations to represent the bar charts or the pie charts. Tableau is built to perform and it provides very quick visual analytics.
Tableau provides you with a wonderful feature of performing logical checks and based on the outcome to do something.
Usage of the CASE statement from programming languages as like C to C++ or even to Java doesn’t differ much. To that point, the CASE statements can be used on RDBMS servers like Oracle, SQL Server and the like. The feature is no different in Tableau Desktop as well, it enables an individual to make logical decision making and then based on the outcome of the case, a specific action can be written to be performed. In plain English, CASE scenario1 THEN perform action1. To be precise, CASE is simpler to use than a complicated and nested IF and ELSE statements.
[Related Article: What Are The Common Use Cases For Tabcmd In Tableau?]
CASE function evaluates the expression and matches the outcome to the values presented as scenarios and then returns the matched value. If there is no match found, then the default return expression will be used. Typically, a CASE statement is used to search for a match to an expression, which is always concise than an implementation using IF and ELSE statements. Now with this basic introduction into the concept of CASE statements, let us take some general examples and see how this can be put to use in Tableau Desktop to achieve what is expected out of the software.
Let us consider a few examples to understand the concepts that we have discussed until now:
CASE [ Runs ] WHEN ‘Six’ THEN 6
WHEN ‘Four’ THEN 4
WHEN ‘Triple’ THEN 3
WHEN ‘Double’ THEN 2
WHEN ‘Single’ THEN 1
Let us take a look at another example to see the usage of the CASE statement:
CASE [Direction] WHEN ‘EAST’ THEN 1
WHEN ‘WEST’ THEN 2
WHEN ‘NORTH’ THEN 3
WHEN ‘SOUTH’ THEN 4
If you want to create CASE statements that could be used in the evaluation of Parameters or Dashboards or Reports, you can create and save them on Tableau Desktop. Let us see how we can create them on Tableau Desktop in the steps provided below:
On the Analysis tab, click on the option ‘Create Calculated Field’
This opens up a new tabular pane for recording your calculation formula
CASE [Region] WHEN 'Shanghai' THEN 'APAC'
WHEN 'Hong Kong' THEN 'APAC'
WHEN 'London' THEN 'EMEA'
WHEN 'Brazil' THEN 'SA'
WHEN 'Texas' THEN 'NA'
A sample screenshot on how this can be saved on Tableau Desktop is shown below:
Once the formula as like that has been shown above is entered, click Ok and save it for further usage.
[Related Article: How To Configure Tableau Server For The First Time?]
In this article, we have tried to give you a brief about what Tableau as software can provide you or your organization with. Alongside those details, we have provided necessary information about CASE statements and also have seen the performance gain that we get over the usage of IF and ELSE statements.
Hope this article is informative enough to provide all the necessary details at one place for your quicker references.
List Of Tableau Courses:
Free Demo for Corporate & Online Trainings.