Quantcast
Channel: InterWorks
Viewing all articles
Browse latest Browse all 2697

Advance with Assist: Nested IF Calculations in Tableau

$
0
0

Question: I’m needing to add multiple layers of logic in Tableau, but I don’t want multiple lines of AND options written out. How can I use multiple IF statements?

Logical calculations take on many forms, and each of us probably has habits that affect the way we write out calculations. This client’s question has several possible solutions, but what we’ll focus on in this blog is nested IF logical statements.

The basic format of an IF statement is:

IF  <insert logical test> THEN <some result> 

ELSEIF….  

ELSE…   

END

Nested IF statements simply add another IF layer after your logical test:

IF  <insert logical test> THEN

IF <insert additional logical test> THEN <some result>   END

ELSEIF….   ELSE…    END

Example of Nested IF Calculations

Nested calculations can be extremely handy when you need to identify different members of the same dimension for the purpose of giving different results to each member.

Perhaps I want to identify Segments and Ship Modes and assign a specific color to the Ship Mode if it met a certain numeric goal. Using Sample Superstore data in Tableau that we all are likely familiar with, let’s look at Consumer over 300 Same Day:

Using a nested IF, I could write the following calculation for our example:

This calculation results in the following:

The post Advance with Assist: Nested IF Calculations in Tableau appeared first on InterWorks.


Viewing all articles
Browse latest Browse all 2697

Trending Articles