The “Cannot use boolean type in IF expression” error in Tableau calculated fields is quite self-explanatory. In Tableau IF statements you’re not able to return boolean fields. Tableau IF statements accept boolean values as inputs, but cannot output boolean values.
Boolean means the value is either TRUE or FALSE. It isn’t a numeric value.
However, there is a workaround to use boolean values. True or False can also be represented as 1 or 0. Tableau recognises 1 and 0 as integers.
How to fix the Tableau error Cannot use Boolean Type in IF expression
Therefore, the way to get around the boolean type error is to convert the boolean value to an integer.
Simply wrap the boolean field in the INT() function.
For example, create a simple calculated field returning a boolean value. The formula 1=1 is boolean because it always returns TRUE. 1 does equal 1. Similarly 1=0 always returns FALSE as 1 does not equal 0.
Next create a calculated field with an IF statement using the just created boolean field. This deliberately creates the Cannot use boolean type error.
Now convert the boolean field to an integer using the INT function. As you can see the error is gone!
Whenever you come across the Tableau error “Cannot use Boolean type” simply convert the boolean values to integers. This will solve the problem.