If you transitioned to tableau from excel like me, you may have found adapting to tableau’s IF function a bit of a pain. The switch from a comma based IF statement to a word based function can take some getting used to... but there’s an underutilised function in tableau that may ease the transition.
Adding an extra I to the start of your IF function will turn it into an IIF function!
The standard tableau IF function takes the following format:
It uses other word based functions such as ELSE and THEN within it to separate the conditions and values.
Whereas, IIF uses commas to separate the elements within the function...
...very much like an IF statement in excel.
The IIF begins with a logical test/condition followed by a comma. Next is the 'then' part of the function which is essentially the 'value_if_true' part of excel's statement, followed by 'else' which is the equivalent of 'value_if_false' in excel.
Where the IIF function differs from an excel IF statement is that following the 'else' clause there is a final optional section for specifying a value for if the condition is unknown or NULL.
While it is definitely worth getting to grips with the standard IF function due to its versatility, if you are at the start of your tableau journey and feeling out of your depth with calculations the IIF function may help to ease your transition.