For some reason, Tableau considers it an error if the branches of an if or case statement evaluate to a boolean type. Please remove this restriction, unless there is some important problem that the restriction avoids. It makes writing some kinds of calculations needlessly complex.
Calculated fields can clearly return boolean types.
The error message that Tableau gives is
Cannot use 'boolean' type in 'case' expression or
Cannot use 'boolean' type in 'if' expression
Here is a useless example, but it seems to show that the restriction is arbitrary and unnecessary. Other examples are not useless, but more complex.
1. if [xxx] > 10 then true else false end // gets an error
2. [xxx] > 10 // works
Both are logically equivalent. The second form is more concise, but both should be legal. There are other situations where first style is easier to work with. For example,
1. if [xxx] > 10 then [yyy] < 5 else [zzz] = 'a' end
2. ([xxx] > 10 and [yyy] < 5) or ([xxx] <= 10 and [zzz] = 'a')
The current restriction is even more clunky with case statements that return boolean expressions. Testing set membership is a boolean operator, so now that Tableau lets you test set membership in calculated fields, this restriction has become more cumbersome.
And while you're at it, allow boolean expressions as arguments to ifnull() also. See https://community.tableau.com/ideas/6970
allow booleans to be first class expressions in calculated fields