EDUCBA

EDUCBA

MENUMENU
  • Explore
    • Lifetime Membership
    • All in One Bundles
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Login
Home Data Science Data Science Tutorials Tableau Tutorial Tableau IF Statement

Tableau IF Statement

Aanchal Singh
Article byAanchal Singh
Priya Pedamkar
Reviewed byPriya Pedamkar

Updated March 18, 2023

Tableau IF Statement

Introduction to Tableau IF statement

In order to test a condition to accomplish a task based on the value returned post-testing of the condition. Tableau provides a logical statement to check a particular condition, represented by an expression, against a certain value or assumption, to determine whether a given condition is TRUE or FALSE, based on which certain tasks get performed if the condition is met, so as to facilitate correct and effective decision making is termed as Tableau IF statement.

ADVERTISEMENT
Popular Course in this category
TABLEAU Course Bundle - 16 Courses in 1 | 2 Mock Tests

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Tableau IF Statement

Logical calculations help you in determining if certain given conditions are true or false. In order to do this decision making it is important to have a function to this. In Tableau, there are different functions that are provided. The IF function helps in determining if a series of expressions are true then the value for the first expression will be returned. In Tableau, there are three variants of the IF function. It has IF, IF-ELSE, and ELSE IF.

1. The IF Condition

The IF Condition returns the result only if the given condition is true. If this condition is not true, then it returns nothing.

Example: If [Marks] > 35 then ‘PASS’

2. The IF-ELSE function

This condition also tests for particular conditions. If the test condition in IF is true, then the statement after the THEN keyword will be returned. If this is False, then the statement after Else keyword is returned. The syntax for If Else in Tableau is as follows:

IF <Expression> THEN <True Statement>
ELSE <False Statement>
END

3. The ELSE IF Function

Whenever there is a requirement of checking multiple conditions the Else If the condition is very useful. The Else If conditions can be used only when the is a previous If or Else if statement which is being failed. This function executes in a sequential manner. It starts checking from the first condition. If the first condition is true then it will execute the statement which is present after the Then keyword. If this condition is false then it will check the next Else if Condition. It will keep on continuing with the else if statements until the condition are satisfied.

Syntax-

IF <Expression1> THEN <True_statement1>
ELSEIF <Expression2> THEN <True_statement2>
ESEIF <Expression3> THEN <True_statement3>
.....
ELSE <False_statement>
END

The IIF Function

  • IIF is a useful function which helps in getting logical functions done. When using this function there are arguments that are to be passed and the argument which is expected is should be a Boolean. If it is not Boolean, then it can be the result of the logical expressions. These results can be further used to provide a Boolean result. If the results of this logical expression evaluate to be True, then IIF will return the value which follows Then.
  • If the results of these logical expressions evaluate to be false, then IIF will return the Else value. As the values that are being returned are Boolean there can be cases where the results are unknown that means they are neither true nor false. This is usually the case when there are null values present in the data. When this happens then the last argument which is passed to IIF is returned as Unknown result. If this is not considered, then the Null value is returned.

Syntax-

IIF(test, then, else [unknown])

Let us now have a look at a few examples in order to understand these functions properly.

  • Consider that A grade has been earned, a certificate needs to be issued. A field should be there to calculate and identify these instances. This can be done easily by either using If Else statement of using the IIF statement.

IF (Letter Grade (Nulls))= ‘A’ then ‘Create Certificate’
Else ‘Do Nothing’
End
IIF(Letter Grade (Nulls))= ‘A’, ‘Create Certificate’, ‘Do Nothing’)

The only difference between these statements is the syntax. The IIF statement is less prone to errors but is not much readable or familiar. The basic difference between these two is that data contains values which yield unknown result through Boolean comparison. This may happen when there is a null value in data. When this happens in If Else statement the unknown results are treated as the same as false results. But when the IIF statement is used then it returns ‘Null’ value for results which will have unknown values.

  • IF test THEN value END/ IF test THEN value ELSE else END

The above function is similar to the IIF function. It distinguishes True, False and Unknown values. On the other hand, the IF statement only cares about the True and not True values. To get the appropriate values in return all logical tests must be performed by using IF THEN ELSE statements.

IF(SUM([Profit]) > 0) THEN 'Performing Good'
ELSE 'Bad Performance'
END

This statement clearly defines when the business is performing good and when it is performing badly. There is no ambiguity present in this scenario.

  • In order to have multiple conditions checked the If THEN ELSE IF can be used.

IF (Letter Grade (Nulls))= ‘A’ then 4
ElseIF (Letter Grade (Nulls))= ‘B’ then 3
ElseIF (Letter Grade (Nulls))= ‘C’ then 2
ElseIF (Letter Grade (Nulls))= ‘D’ then 1
Else 0
End

These statements are easier and less ambiguous when it comes to the IIF statement. They have their separate conditions defined. It is much easier to write and understand. When it comes to If statements in Tableau, IIF should be used when the calculation is simple, or you are not sure about the data quality of the field under question.

Conclusion

  • Tableau, unlike other tools, does provide logical functions. These functions can be easily used as requirements. The If conditions with its variants can be easily implemented in Tableau. It also has IIF and ELSEIF which provide a mechanism for unknown values being replaced with NULL. It provides normal conditional checks as well.
  • The other logical functions are also useful, and Tableau is hence being used in the market with these features in hand. It also has the functionality to create logical calculations where all these logical functions can be used, and the reports can provide more accurate data and give an accurate analysis to the users.

Recommended Articles

This has been a guide to Tableau IF Statement. Here we discuss the Introduction, three different variants of the IF function with their respective syntax and explanation. You can also go through our other suggested articles to learn more –

  1. What is Tableau?
  2. Looker vs Tableau
  3. How to create a Set in Tableau?
  4. How To Install Tableau
  5. If Else Statement in Python | Examples
  6. Introduction to If Else Statement in R
  7. If Statement in Python
  8. Guide to If Statement in Shell Scripting
ADVERTISEMENT
WINDOWS POWERSHELL Course Bundle - 7 Courses in 1
19+ Hours of HD Videos
7 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
SALESFORCE Course Bundle - 4 Courses in 1
24+ Hours of HD Videos
4 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
MINITAB Course Bundle - 9 Courses in 1 | 2 Mock Tests
35+ Hour of HD Videos
9 Courses
2 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
SAS PROGRAMMING Course Bundle - 18 Courses in 1 | 8 Mock Tests
123+ Hours of HD Videos
18 Courses
8 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

🚀 Extended Cyber Monday Price Drop! All in One Universal Bundle (3700+ Courses) @ 🎁 90% OFF - Ends in ENROLL NOW