ThunderStorm
ThunderStorm

Reputation: 155

IF Statement in tableau

I have written the folowing condition as per the some online tutorial

IF [Nationality]="England" 
   THEN "England" 
ELSEIF [Nationality]="Germany" 
   THEN "Germany" 
ELSE "Others" 
END

But continuously getting an error:

"The formula must be a boolean formula"

What is wrong in the condition?

I have tried other statements too CASE and CONTAINS for them too same error.

It should accept.

Upvotes: 1

Views: 1118

Answers (2)

Pulkit Bansal
Pulkit Bansal

Reputation: 21

Seems like you are trying an IF condition in one of your filters. In order for a filter condition to be valid, it should always evaluate to True or False. In your example, you may need to modify your code as below:

(IF [Nationality]="England" 
    THEN "England" 
 ELSEIF [Nationality]="Germany" 
     THEN "Germany" 
 ELSE "Others" 
 END) = <Some Column>

In the above code you are evaluating your IF condition against some column value.

Hope this helps!

Upvotes: 0

MonteCarloSims
MonteCarloSims

Reputation: 1771

It looks like you might be trying to filter by condition as pictured below. This field does, indeed, require a boolean condition. It needs to know whether to filter out (False) or keep in (True).

Instead of using this dialog box, try the following:

Right Click [Nationality] Field > Click "Create..." > Calculated Field

If you put your calculation in the dialog box that pops up, it will work. From there you can filter accordingly.

enter image description here

Upvotes: 1

Related Questions