Lead magnet - project 1.png
  • Bernard K

Guide to Nested IF Calculations in Tableau

nested if calculations in tableau


Nested IF statement, is simply an IF statement placed inside another IF statement. This logical function is useful when you want to test more than one condition (when you want to test one condition followed by another).

Syntax – Basic IF statement

IF <Logical test> THEN <Result_1>

ELSEIF <Logical test> THEN <Result_2>


ELSE <Result_n>


Syntax – Nested IF Statement

IF <Logical test> THEN

IF <Logical test> THEN <Result_1> END




Example of Nested IF calculation

Let’s say using the sample-superstore data set, you would like to populate the average time it took to ship products by Region and Ship Mode (for a past period).

This is how the current period might look like.

(Simple view showing the average time to ship products by Region and Ship Mode)

Assuming the past metrics are as follows.

You can populate the above metrics using this simple nested-if calculation.

nested if statement in tableau

Adding the above calculation to the view populates the past metrics as shown in the resulting view below.

(Notice the nested calculation has 5 IF statements and 5 END lines to mark the end of each if statement within the calculation)

Useful: Explore how to dynamically group and ungroup dimensions using nested if calculation

Useful: Explore Nested CASE-WHEN statement in Tableau

I hope this article was helpful to you. If you are interested in receiving more Tableau tips and tricks, kindly join our mailing list by subscribing below.

If you like the work we do and would like to work with us, drop us an email on our Contacts page and we’ll reach out!

Thank you for reading!

Black & white.jpg

About Me

More About the Author

Bernard K

Analytics Consultant | 3X Tableau Certified

Bernard is a data analytics consultant helping businesses reveal the true power of their data and bring clarity to their reporting dashboards. He loves building things and sharing knowledge on how to build dashboards that drive better outcomes.

Let’s discuss your data challenges! Let’s work together!