10 Replies Latest reply: Feb 27, 2018 2:36 AM by Andy Weir

# Color by Alternative Measure

I have a bar graph that has one measure and two alternative measures. I want to be able to color each based on its own expression. Therefore, when I select the first measure, the bars should be colored based on their values. When I select the second (alternative) measure, the bars should be based off of their values. However, when I have the colors set to "By measure," it colors all measures by the values of the first one.

Please let me know if there is a way to work around this.

As always, thank you.

Aaron

• ###### Re: Color by Alternative Measure

Have you tried making your measures master items and setting the colours there?

Then in your chart use library colours instead of setting by measure.

Regards

Andy

• ###### Re: Color by Alternative Measure

This would work if the master items had a "color by expression" or a gradient feature. I want each of the alternative measures to be on a diverging color gradient.

Is there a way to write a color code that would change based on the measure that is selected? Like:

If({Selected Measure}=Alternative1, {ColorCode1}, If({Selected Measure}=Alternative2,{ColorCode2},etc)) ?

Obviously, this wouldn't work, but is there any way to do something similar?

• ###### Re: Color by Alternative Measure

Not possible. This is an known limitation:

• ###### Re: Color by Alternative Measure

we can take two dimensions, one main and another alternate dimension and take one measure.

set color by measure put expression:- in color by measure:-

if(CategoryName='Babywear','green',Yellow())

• ###### Re: Color by Alternative Measure

sorry it will work when you use color by alternate dimension.

when you will select different different dimension then it will work accordingly

• ###### Re: Color by Alternative Measure

Let's assume u have 2 measures:

sum(Sales)

Sum(Production)

create an Inline table:

MeasureID,Measure

1, SalesMeasure

2, SalesProduction

];

iadd this new Measure field as a filter

in ur chart,

create a measure as follow:

if(MeasureID=1,sum(Sales),sum(Production))

and color by measure.

Now, u'll have sthing like this:

• ###### Re: Color by Alternative Measure

This fulfills the purpose, but it takes up more space and is more complicated for the user. Is there any other way that you can think of that would do the same thing without having to include a filter box?

Thanks.

• ###### Re: Color by Alternative Measure

Nope; it's the only way I can think of (and really think it's the only way)

for the space; u can use this filter :

https://github.com/countnazgul/Qlik-Sense-Styled-Lists-Extension

It take nearly no places + u can force it to be always selected (selection by default)+ force the user to select only One value

• ###### Re: Color by Alternative Measure

Taking omarbensalem solution you could make it a nicer layout by using a variable set by button extension i.e qsvariable.