Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to use custom colours in a stacked bar chart

Hi there,

I am struggling to colour a stacked bar chart in custom colours. If you take belows chart as an example, I would like to e.g. replace the green with black, the purple with turquoise etc.

This example chart is auto-colour by QlikSense in the multicolored>12 colors mode.

stacked-bar chart.PNG

I defined my custom colours as e.g. "kGreen", "kBlue" and usually use nested if-expressions to custom-colour my charts.

With the stacked bar chart, however, the issue is that my six different measures are six columns of the same facts table and the if-statements don't work.

Thank you very much for your help!

28 Replies
reddy-s
Master II
Master II

Hi David,

This should be an easy way to achieve this.Capture.PNG

Find the sample qvf attached.

- Sangram

Not applicable
Author

Hello,

I am struggling with a "problem" in Qlikview Could someone help me please ?

I have created a stacked bar chart. 2 expressions and 2 dimensions, one is year-month and one is calculated (3 VALUES, 'achieved', 'justmissed' and 'missed'). I would like to display 'achieved' in green, 'justmissed' in yellow and 'missed' in red.

To achieve this, I have created 2 variables:

  1. vBenchLabel that returns 'Achieved', 'Just Missed', or 'Missed'
  2. vBenchColor=pick(match($(vBenchLabel),'Missed','Just Missed','Achieved'),lightred(),yellow(),lightgreen())

and the definition back ground color of the first expression is $(vBenchColor)

BUT the 3 segments are RED.

thank you very much

Nasser

reddy-s
Master II
Master II

Hi Nasser,

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() )))

Not applicable
Author

Hi Sangram,

thank you very much for you quick answer.

I am trying to implement your solution but I don't know what is the expression1, expression2, expression3 in the measure.

I have 2 measures

  1. count(action) / count(action TOTAL year) ==> percentage used for the size of each stacked segment
  2. count(action)==>used to display the number of action

so what do you mean about expression1, expression2, expression3 ?

Many thanks

reddy-s
Master II
Master II

Hi Nasser,

Is it possible to attach a sample qvf so it will be easier to explain?

Thanks

Sangram

reddy-s
Master II
Master II

One more thing,

Am I right that the values in the field action is as follows:

  Action

'Achieved'

'Just Missed'

'Missed'

?

Not applicable
Author

Hi Sangram,

I would like, but I just have a qvw file. I am working in a qlikview application (not qlik sens).

do you want me to send you the qvw file ?

Nasser

Not applicable
Author

No exactly.

An action is just a number (primary key). An action has an attribute "bench" which can be Achieved, Just Missed or Missed. let's consider (as an example) 99 actions (77 achieved + 10 Just Missed and 12 Missed) in march

The purpose is to display this bar

reddy-s
Master II
Master II

Hi Nasser,

QVW would be great 🙂

Thank you.

reddy-s
Master II
Master II

Assuming that values in the field Action are -> Bench = Achieved, JustMissed and Missed.

Try these expressions:

Dimension 1: year-month

Dimension  2: Action

Measure : if(Action = 'achieved',Count({$< Action = {'achieved'} >}Action),

               if(Action = 'justmissed',Count({$< Action = {'justmissed'} >}Action),

               if(Action = 'missed',Count({$< Action = {'missed'} >}Action) )))

Colour Expression:

               if(Action = 'acheived', lightgreen(),

               if(Action = 'justmissed', yellow(),

               if(Action = 'missed', lightred() )))