Tableau Cannot use boolean type in IF expression


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.

using 1=1 in a Tableau calculated field to create a boolean result
Create a calculated field of boolean data type

Next create a calculated field with an IF statement using the just created boolean field. This deliberately creates the Cannot use boolean type error.

create the cannot use boolean type in if expression error
Create the Cannot use boolean type in if expression error

Now convert the boolean field to an integer using the INT function. As you can see the error is gone!

wrapping a Tableau boolean in INT to stop the cannot use boolean type in if expression
Wrap the boolean in INT and it’s no longer a boolean

Whenever you come across the Tableau error “Cannot use Boolean type” simply convert the boolean values to integers. This will solve the problem.

2 thoughts on “Tableau Cannot use boolean type in IF expression”

  1. thanks for sharing the info. please keep on sharing the useful information about the tableau


Leave a Comment