1 2 Previous Next 17 Replies Latest reply on Mar 14, 2019 9:38 AM by Robert Breen

# KPI labels for colors only shows 1 option

i have 8 metrics and 3 conditions, if >0, if <0, or =0 for each metric... i wrote this calc in order to color and add a shape based on these conditions...

BUT, i only get 1 value "positibe growth".  what am i doing wrong... here is screenshot

• ###### 1. Re: KPI labels for colors only shows 1 option

Hello Jon,

Within an if statement, it only moves to the elseif if the first part of the calculation returns false. In your case, at least one of your measures is greater than zero so the calculation stops there and skips over the elseif.

Robert

• ###### 2. Re: KPI labels for colors only shows 1 option

thanks Robert i cant upload the wb...

whats another option?

• ###### 3. Re: KPI labels for colors only shows 1 option

Can you replicate the problem using this data? I need to see exactly what you are trying to accomplish.

just a simple example of what you are trying to do will help a lot.

• ###### 4. Re: KPI labels for colors only shows 1 option

Here's what I think you are going for.

It's not possible to color each measure differently on the measure values shelf, but you can create each color calculation separately, and use a dashboard to show all calculations.

see attached.

Robert

• ###### 5. Re: KPI labels for colors only shows 1 option

i have 4 metrics, at any time depending on the filters etc. they can be either above 0, below 0 or = to 0

take superstore sales... and use Profit, Sales, Growth.  but when i drag it onto my view depending on the filters those metrics (profit, sales, growth) will change depending on filters in specific sheet...either above 0, below 0 or = to 0

so why do i only see 1 value when i drag it into color... shouldnt i see all 3 conditions and be able to color according... i always only get "positive" even if i have a negative value in the view

if

Profit >0 OR

Sales > 0 or

growth > 0 then "positive"

ElseIF

Profit <0 OR

Sales < 0 or

growth < 0 then "negative"

elseif

Profit =0 OR

Sales = 0 or

growth = 0 then "flat"

end

• ###### 6. Re: KPI labels for colors only shows 1 option

Or you could color each of the measures separately like this attachment. It's just a little harder to control the middle color that way.

• ###### 7. Re: KPI labels for colors only shows 1 option

The if statement is going line by line, and once it reaches a True value, it stops. It will not test if each  of your or statements is true.

You are trying to test each measure separately. that is not possible with one calculation.

• ###### 8. Re: KPI labels for colors only shows 1 option

in this scenario, if profit is greater than 0, it will not test if sales is greater than 0 as it already tested true for the line before. The answer will always be "Positive" if profit is true.

Profit >0 OR

Sales > 0 or

growth > 0 then "positive"

ElseIF

Profit <0 OR

Sales < 0 or

growth < 0 then "negative"

elseif

Profit =0 OR

Sales = 0 or

growth = 0 then "flat"

• ###### 9. Re: KPI labels for colors only shows 1 option

but what is it relative to?  all my data?  or whats in my view?

if my view has 1 value and 1 metric and it is positive then this coloring calculation should  be colored as "positive"

if the view has 1 value and 1 metric it is negative then this coloring should be "negative"

maybe here is a better screenshot... the view shows 1 metric with 1 value...the value is negative but the only option is "positive growth"

• ###### 10. Re: KPI labels for colors only shows 1 option

The if statement is not testing each measure in the view, it is testing each row in your data, and outputting True or False.

Here's an example of what the calculation is doing. The answer can only be true or false. It cannot output true or false for each measure separately.

• ###### 11. Re: KPI labels for colors only shows 1 option

Take a look at this sheet. Does this output what you are looking for?

• ###### 12. Re: KPI labels for colors only shows 1 option

so how my data is sorted determines how this calculation works?

the point of my creating 3 scenerios is to paint 0.0 as black and not green, and if i use 3 steps, it beocmes a range so .03 and -.03 take on the middle color

how can i create hard break on colors like i have in my calculation?

• ###### 13. Re: KPI labels for colors only shows 1 option

thanks but i want to color 3 different scenerios, is there a way to write a calculation to accomplish this?

• ###### 14. Re: KPI labels for colors only shows 1 option

In this solution, there isn't a good way to have a constant middle color.

If you create three separate sheets like this example, you can create three distinct colors. (see attached)

What your trying to do just isn't possible with tableau. In your example, there is only one row. It looks like this. There can only be one answer. positive, negative, or flat. It cannot return an answer for each measure. It just reads left to right on your one row and answers the question. once it gets a true, it returns "Positive"

Attached is another way to do it. You can create different sheets and add them all to a dashboard with different color ranges.

1 2 Previous Next