Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

reddys310
Honored Contributor II

Re: How to use custom colours in a stacked bar chart

Hi David,

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

Find the sample qvf attached.

- Sangram

Not applicable

Re: How to use custom colours in a stacked bar chart

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

reddys310
Honored Contributor II

Re: How to use custom colours in a stacked bar chart

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

Re: How to use custom colours in a stacked bar chart

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

reddys310
Honored Contributor II

Re: How to use custom colours in a stacked bar chart

Hi Nasser,

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

Thanks

Sangram

Highlighted
reddys310
Honored Contributor II

Re: How to use custom colours in a stacked bar chart

One more thing,

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

  Action

'Achieved'

'Just Missed'

'Missed'

?

Not applicable

Re: How to use custom colours in a stacked bar chart

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

Re: How to use custom colours in a stacked bar chart

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

reddys310
Honored Contributor II

Re: How to use custom colours in a stacked bar chart

Hi Nasser,

QVW would be great :-)

Thank you.

reddys310
Honored Contributor II

Re: How to use custom colours in a stacked bar chart

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