Logical Functions | Logic Statements in Tableau
Stay updated with latest technology trends
Join DataFlair on Telegram!!
In this tableau tutorial, we are going to study about Tableau Logical functions, the different logic statements with examples that we can perform in Tableau.
So, let us start tableau Logical Functions.
2. Tableau Logical Functions
An operator could be an image that tells the compiler to perform specific mathematical or logical manipulations. Tableau encompasses a variety of operators accustomed produce calculated fields and formulas.
Read about Tableau Paged Workbook & Steps to Create it
Following area unit the main points of the operators that area unit obtainable and therefore the order (precedence) of operations.
The basics logical statements in tableau are as follows:
a. CASE Statement
CASE expression once value1 THEN return1 once value2 THEN return2 … ELSE default come back finish
The CASE statement is employed to perform a logical check and come back values supported the result. CASE operates are often rewritten as AN IF function, however, the CASE Logical functions are usually times less complicated to jot down and shorter.
Here’s AN example of a formula:
This CASE statement creates a replacement field by exploring the country field. Once the worth “United States” is found, it uses “USA.” once “United Kingdom” is found, it uses “UK.” All alternative values receive the worth “World.”
Let’s revise Adding Worksheets And Renaming Worksheet In Tableau
b. IF Statement
IF check THEN worth finish / IF check THEN worth ELSE else finish
Tableau IF statement creates a logical check. IF check is true THEN do y. The check a part of the operations should be a mathematician, either by employing a mathematician field within the knowledge supply or because of the results of AN expression victimization operators or logical comparisons (AND, OR, NOT).
Here’s AN example:
IF test1 THEN value1 ELSEIF test2 THEN value2 ELSE else finish
You can expand the practicality of the IF logical functions with the ELSEIF by adding extra IF-THEN statements. for instance, here we will recreate our CASE formula on top of victimization AN IF-THEN-ELSEIF statement:
Same result as our CASE operate, grouping all alternative values into World and abbreviated the USA and United Kingdom of Great Britain and Northern Ireland.
c. IFNULL Statement
The IFNULL statement primarily runs a true/false check on whether or not the worth within the tested field is NULL. The primary worth within the operate is employed if the worth isn’t null, and also the second is employed if it’s null.
If any country’s Total Population doesn’t have a price, then it’ll be reset as zero and removing the null from the fresh created field.
Let’s watch Tableau Data Extract – How to do Data Extraction in Tableau
d. IIF Statment
IIF(test, then, else, [unknown])
The IIF statement is extremely just like the IF operate on top of. It primarily creates a shorthand operate for AN IF-THEN-ELSE statement with the additional advantage of being to outline a price with the ultimate argument if the check yields AN unknown result. Remember, a bit like the IF operate, the check should be mathematician by knowledge kind or lead to a mathematician worth as a results of the check.
Let’s take a glance at AN example:
If the sphere take advantage of modification is a smaller amount than five-hitter then my formula on top of can come back a price of Poor, otherwise it’ll come back sensible.
e. ISDATE Statement
The ISDATE statement tests whether or not the string argument are often born-again to a legitimate date (TRUE) or if it cannot (FALSE). Here’s AN example:
The on top of a formula is approved by Tableau as a result of the sphere that we have a tendency to used is so a string knowledge kind, however, each result can clearly be FALSE. you would possibly use this logical functions. If your date is formatted in an exceeding vogue you would possibly not acknowledge, like ISO 8601. Here’s AN example:
The on top of worth represents Sept one, 2014 and so may be a valid worth for a date.
Learn Tableau Save, Reorder and Delete Worksheet
f. ISNULL Statement
Another straightforward statement, ISNULL, merely tests whether or not AN expression is null (TRUE) or not (FALSE).
If you wish to filter null values from your image, you’ll be able to filter null values with the Filter card.
g. ZN Statement
The last logical Functions are that the atomic number 30 operate. It’s a variation on the ISNULL and IFNULL operate. Atomic number 30 tests to ascertain if a operate is null, and if it’s, it’ll come back a price of zero.
The first time you see a listing of logical functions, there’s the inevitable hesitation on what all of this suggests. Currently that we’ve suffered all, hopefully, you’ll notice them helpful in investing your knowledge and your image even over before. If you wish to leap in and learn a lot of regarding once to use these functions, here’s a good post.
Let’s Discuss Tableau Highlight Table – Steps to Build Highlight Table
In this tutorial, we studied the different logical functions: CASE Statement, IF Statement, IFNULL Statement, IIF Statment, ISDATE Statement, ISNULL Statement, ZN Statement in a tableau with examples, and how we can use Logical statements in tableau to perform various operations. With this, we complete yet another milestone in our journey. Furthermore, if you have any query, feel free to ask in a comment section.
See Also- Tableau Bubble Chart & How to Create Tableau Heat Map