7 Replies Latest reply on Nov 2, 2016 7:48 AM by Joe Oppelt

# How do I use true/false dimensions in a logic calculation?

I want to create a dimension called school location which has the value "Barton" if the value of a dimension called servicename includes the word "Barton" and has the value of "Joplin" if the value of servicename includes the word "Joplin" etc.

I created calculated fields for each school location as follows (see Barton example below)

I then tried to create a logic calculation as follows (see below_

However, the calculation didn't work. I got this message:

What did I do wrong? Thanks for your help!

• ###### 1. Re: How do I use true/false dimensions in a logic calculation?

IF [Boolean variable here] THEN (do whatever you need to do if true) END

Or

IF NOT [Boolean] then (do whatever should be done if false) END

• ###### 2. Re: How do I use true/false dimensions in a logic calculation?

Thanks Joe! This works if I have only one Boolean condition. See below.

However, it doesn't work with multiple Boolean conditions, which is what I need. See below.

Do you (or anyone else) have any other suggestions? Many, many thanks.

-Amelia

• ###### 3. Re: How do I use true/false dimensions in a logic calculation?

Should work.

Upload a packaged workbook.  (Let me know what Tableau version you are using.)

I'll check it out.

The error message indicates that one of those fields is not a Boolean but a string.  I'm sure you've checked that out though.

• ###### 4. Re: How do I use true/false dimensions in a logic calculation?

Hey Amelia,

I don't know if you've tried this method yet, but it appears that you are taking this as a two step process when you can simplify it to a one step with the below calculation.

IF CONTAINS([servicename], 'Barton') THEN 'Barton'

ELSEIF CONTAINS([servicename], 'Joplin') THEN 'Joplin'

ELSEIF CONTAINS([servicename], 'Ogsleby') THEN 'Ogsleby'

ELSEIF CONTAINS([servicename], 'Westcott') THEN 'Westcott'

ELSEIF CONTAINS([servicename], 'Perspectives') THEN 'Perspectives'

ELSE 'School Location Unknown'

END

If I understood your use case correctly, the above solution may be able to help you out.

KJ

• ###### 5. Re: How do I use true/false dimensions in a logic calculation?

Amelia,

I believe you are just missing equal signs in your if statement.

Instead of IF [Barton Location] TRUE THEN 'Barton' try

IF [Barton Location]=TRUE THEN 'Barton' etc...

• ###### 6. Re: How do I use true/false dimensions in a logic calculation?

Thanks KJ! I had tried the "contains" command earlier but I guess I got the syntax wrong. This worked!!!

Amelia

• ###### 7. Re: How do I use true/false dimensions in a logic calculation?

Amelia -- That's a good solution, but don't go away thinking that you can't use multiple Booleans in an IF statement.

Just saying.