Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Custom Colors for Stacked Bar Chart

I created a few stacked bar charts that show the same dimension for the bar. The colors are consistant from one graph to another. For instance, 'Basic' can be represented by blue on one chart and could be green on another. I know you can create an expression to force the colors to be consistant, but I am unable to also have a legend that shows the colors and what they represent. Can you use custom colors and have a legend? Is there a better way to force the colors to be consistant among all the charts?

6 Replies
morganaaron
Specialist
Specialist

Hi Laura,

Have a look at this post for more information on the best way to approach this!

Consistent Dimension Colors - The Qlik Fix! The Qlik Fix!

Marcellino_Groothof
Contributor III
Contributor III

Hi,

Try this:

Tablad: presentation: show legend.

Flag persistent colors in tabblad colors.

Greetings,

Marcellino

durgabhavani
Creator III
Creator III

Hi Laura,

Definetly stacked bar chart contains multiple expressions.

So you can go to the individual expression and click on + symbol on expression and give the background color definition to the expression (ex: RGB(255,124,234) or lightgreen()) to get the color what ever you want.

Then you can achieve your output!

Hope this helps!

Thanks,

Durga

Not applicable
Author

HI Laura


Another trick for consistent dimension colours is this useful snippet from Barry Harmsen over at QlikFix

Consistent Dimension Colors - The Qlik Fix! The Qlik Fix!

Thanks

Please mark answers as correct or helpful so other users can identify the same solution quickly

reddy-s
Master II
Master II

You can colour a stacked bar chart in the following way. Take this as an Example.

Use these expressions:

Dimension 1: year-month

Dimension  2: valuelist( 'achieved', 'justmissed' and 'missed')

Measure : if(valuelist( 'achieved', 'justmissed' and 'missed') = 'achived',<expression1>,

               if(valuelist( 'achieved', 'justmissed' and 'missed') = 'justmissed',<expression2>,

               if(valuelist( 'achieved', 'justmissed' and 'missed') = 'missed',<expression3> )))

Colour Expression:

               if(valuelist( 'achieved', 'justmissed' and 'missed') = 'achived',lightgreen(),

               if(valuelist( 'achieved', 'justmissed' and 'missed') = 'justmissed',yellow(),

               if(valuelist( 'achieved', 'justmissed' and 'missed') = 'missed',lightred() )))

Check this for a QVF sample.

How to use custom colours in a stacked bar chart

Not applicable
Author

Hi Sangram,

Is this approach possible when the expressions in the measures are also if statements? I have included the Dimension expression we have working and what I think the colour expression should be. But not sure if I can combine the two as this doesn't seem to work:

if(valuelist('<£50k','£50k-150k','£150k-500k','£500k-1m','£1m+')='<50k',if(aggr(sum([Revenue Amount - $(=ChooseCurrency)]),DW_Dim_Client_PSK) <50000, '<£50k'

Current Dimension Expression that works and auto colours appropriately:

if(aggr(sum([Revenue Amount - $(=ChooseCurrency)]),DW_Dim_Client_PSK) >= 1000000, '£1m+',

  if(aggr(sum([Revenue Amount - $(=ChooseCurrency)]),DW_Dim_Client_PSK) >= 500000, '£500k-1m',

    if(aggr(SUM([Revenue Amount - $(=ChooseCurrency)]),DW_Dim_Client_PSK) >= 150000, '£150k-500k',

    if(aggr(sum([Revenue Amount - $(=ChooseCurrency)]),DW_Dim_Client_PSK) >= 50000, '£50k-150k',

    if(aggr(sum([Revenue Amount - $(=ChooseCurrency)]),DW_Dim_Client_PSK) <50000, '<£50k'

)))))

Colour Expression (for Rgb colours we have added to our data load to pick from):

if(valuelist('<£50k','£50k-150k','£150k-500k','£500k-1m','£1m+')='<50k',RgbBlue,

if(valuelist('<£50k','£50k-150k','£150k-500k','£500k-1m','£1m+')='£50k-150k',RgbOrange,

if(valuelist('<£50k','£50k-150k','£150k-500k','£500k-1m','£1m+')='£150k-500k',RgbRed,

if(valuelist('<£50k','£50k-150k','£150k-500k','£500k-1m','£1m+')='£500k-1m',RgbGree,

if(valuelist('<£50k','£50k-150k','£150k-500k','£500k-1m','£1m+')='£1m+',RgbLightBlue

)))))

Thank you,

Emma