11 Replies Latest reply on Jul 10, 2018 8:00 AM by EKENE ODIGBOH

Show color ranges

Hello,

I created a map showing legend with five different colors:

How can I create the legend below including ranges to those colors as seen below:

I tried creating a calculated field with this code below and I keep receiving error that '' Expected

Closing Parenthesis for the expression starting at character 4.

IF (SUM of ED VISITS)<200
THEN 'GRAY'

ELSE IF (SUM of ED VISITS)>=300
AND (SUM of ED VISITS)<400 THEN 'LIGHT RED'

ELSE IF (SUM of ED VISITS)>=500
AND (SUM of ED VISITS)<600 THEN 'DARK RED'

ELSE IF (SUM of ED VISITS)>=700 AND (SUM of ED VISITS)<800 THEN 'LIGHT BLUE'

ELSE 'DARK BLUE'

END

Thank you

Ekene

• 1. Re: Show color ranges

Good morning

there are issues in the syntax

the general form is

if     (clause ) then ELSEIF clause then        ... end

the connector is ELSEIF not ELSE IF

additionally if you want to sum a measure the syntax is sum([Ed Visits] )

you will need to correct in all places

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

1 of 1 people found this helpful
• 2. Re: Show color ranges

Hi Ekene,

IF (SUM of ED VISITS)<200 THEN 'GRAY <200'

ELSEIF (SUM of ED VISITS)>=300 AND (SUM of ED VISITS)<400 THEN 'LIGHT RED 300-400'

ELSEIF (SUM of ED VISITS)>=500 AND (SUM of ED VISITS)<600 THEN 'DARK RED 500-600'

ELSEIF (SUM of ED VISITS)>=700 AND (SUM of ED VISITS)<800 THEN 'LIGHT BLUE 700-800'

ELSE 'DARK BLUE 800+'

END

HTH

Peter

• 3. Re: Show color ranges

Hi,

More simplest way,

IF [SUM of ED VISITS]<200 THEN 'GRAY <200'

ELSEIF [SUM of ED VISITS]<=400 THEN 'LIGHT RED >=200-400'

ELSEIF [SUM of ED VISITS]<=600 THEN 'DARK RED >400-600'

ELSEIF [SUM of ED VISITS]<=800 THEN 'LIGHT BLUE >600-800'

ELSE 'DARK BLUE 800+'

END

Note: If above doesn't return the correct value then aggregate your measure SUM([SUM of ED VISITS]) in the above calculation and check.

Mahfooj

1 of 1 people found this helpful
• 4. Re: Show color ranges

Hi,

There were two issues in your calculation:

1. "ELSEIF" is a single word

2. use "[]" when your measure /dimension name contains space.

below is the correct syntax.

IF ([SUM of ED VISITS])<200 THEN 'GRAY'

ELSEIF  ([SUM of ED VISITS])>=300 AND (SUM of ED VISITS)<400 THEN 'LIGHT RED'

ELSEIF([SUM of ED VISITS])>=500 AND ([SUM of ED VISITS])<600 THEN 'DARK RED'

ELSEIF ([SUM of ED VISITS])>=700 AND ([SUM of ED VISITS])<800 THEN 'LIGHT BLUE'

ELSE 'DARK BLUE'

END

• 5. Re: Show color ranges

Thank you very much. This was very helpful.

• 6. Re: Show color ranges

Thank you Peter. This was helpful but then I noticed that some of the ED visits were not in the range they were supposed to be. It is fixed now.

• 7. Re: Show color ranges

Thank you very much.

• 8. Re: Show color ranges

Another Question

How can I create these tables below in tableau?

Thanks

Ekene

• 9. Re: Show color ranges

Hi,

Thank you very much, it was very helpful.

How can I create colors and assign 1,2,3,4,5 beside the colors. The 5 stars will have a color but beside it will be 5 and so on. So 5 will have a color and theN Excellent beside it. See below

How can I create these tables below in tableau?

Thank you

Ekene

• 10. Re: Show color ranges

Hi,

Its a good practice to first close the original thread by marking the most deserving reply as correct so that other can benefits who have similar query. In this you can mark my answer as correct.

Going forward, for any new query you should start a new thread.

However, here is my approach for your second question.

You can try something like this, create a calculated field using below formula

IF SUM([Sales])< 10000 THEN '★'

ELSEIF SUM([Sales]) < 50000 THEN '★★'

ELSEIF SUM([Sales]) < 150000 THEN '★★★'

ELSEIF SUM([Sales]) < 200000 THEN '★★★★'

ELSE '★★★★★'

END

Mahfooj

1 of 1 people found this helpful
• 11. Re: Show color ranges

Thank you very much Khan! Sorry for not starting a new query in a new thread. Would you be able  to assist with question 1?

Ekene