Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

Appearance "Color by measure" not working

Hi experts

for master item measures I have created this code for the appearance area:

=if([KOK], '#a54343',
if([GER], '#26a0a7',
if([CD], '#79d69f',
if([AB ], '#ec983d',
if([Manufacturing ZXF], '#70ba6e',
if([Manufacturing ABS], '#b0afae',
if([PI ], '#65d3da',
if([External hours ], '#f9ec86',

))))))))

But this colour by measure is not working, the result in the (stacked) bar chart is gray:

TomBond77_0-1652437060317.png

 

Any ideas? 

Thank you, tom

 

Labels (3)
1 Solution

Accepted Solutions
TomBond77
Specialist
Specialist
Author

I solved it. In the master items measures you can perform colours.

View solution in original post

4 Replies
Andrei_Cusnir
Specialist
Specialist

Hello,

 

if my understanding is correct, you have used the expression in "Bar chart > Appearance > Colors and legend > Select measure".

 

If this is the case, then there are probably a couple of issues with this approach:

  1. Color by measure is a feature that colors the bars based on a range value. An expression example is Sum(Value), where the bars will be colored based on the Sum() of Sales and smaller sales values will be colored with gray, while bigger sales values will be colored by blue.
  2. In your expression you have used nested If statements with the logic if([KOK], 'COLOR', 'DIFFERENT_COLOR'). This means that [KOK] is an field within the dataset, which means that the statement on its own, will always be False.
  3. To confirm the point 2, you can create a Table chart, add [KOK] as field and add an a measure expression if([KOK], 1, 2). You will notice that for all the records the result is "2", which means that the expression is always evaluated as false in this case.
  4. One thing that you can do to resolve this expression is to have an comparison in the condition. For example =if([KOK] > 10, 1, 2). This means that for all the values of field [KOK] grater than 10, the response will be 2, otherwise it will be 1. Then instead of 1 and 2 you can use the color codes that you want.
  5. However, the suggestion in point 4 will still not work in your use case scenario, because "Color by measure", requires an expression based on which it will color code the values with the selected "Color scheme" not the codes that you provide within the expression.

 

I hope that this information was helpful. In case I have misunderstood the use case scenario, please elaborate in detail to the issue that you are facing. However, if you believe that this information helped you resolve your concerns, please mark it as accepted solution to give further visibility to other community members.

 

 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂
HugoRomeira_PT
Creator
Creator

Hello,

It seems to me that you want to color by dimension and not by measure.

1. Create the dimension, by adding the field name (where you have the options: KOK, GER, CD, AB...)

HugoRomeira_PT_0-1652439839536.png

 

2. After edit the dimension and select value colors, and add the color to each value

HugoRomeira_PT_1-1652439937771.png

 

3. Finally drag and drop the master dimension on top of your chart and select color by dimension.

 

Hope it helps.

Best regards

Hugo Romeira

If the issue is solved please mark the answer with Accept as Solution.
If you want to go quickly, go alone. If you want to go far, go together.
TomBond77
Specialist
Specialist
Author

Thanks Hugo

I have month and this other dimension you are referring to. Where should I select the later dimension?

TomBond77_0-1652444462698.png

 

TomBond77
Specialist
Specialist
Author

I solved it. In the master items measures you can perform colours.