Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
bashar_f
Contributor

Color Expression on stacked bar chart based on measure

Hi, I have a stacked bar chart that has one dimension and two measures. the dimension is 'Customer' and the measures are 'SuccessCDR' and 'FailCDR', on the stacked bar chart, I want the 'SuccessCDR' to show as lightgreen() instead of blue and 'FailCDR' to show as lightred() instead of red.

Untitled.jpg

Every example i have found is checking a value like

if(Type='Discussion',blue(),if(Type='Replies',Green(),Red()))

Except in my case there is no field value, I just want that measure to show up with a different color expression.

Something like this

if('SuccessCDR',green(),if('FailCDR',Red()))


How do i do this?



18 Replies

Re: Color Expression on stacked bar chart based on measure

You must have a field that contains the 'SuccessCDR' and 'FailCDR' values, so you should be able to use something like :

     if(YourField='SuccessCDR',green(),if(YourField='FailCDR',Red()))

Partner
Partner

Re: Color Expression on stacked bar chart based on measure

Simply change the first and second color in the color tab of the chart properties or set the background color of the expressions by clicking on the + sign in front of the expression and use LightGreen() or LightRed() as expression for the background color.

BGColor.png

Not applicable

Re: Color Expression on stacked bar chart based on measure

Hi,

Go to background color of first expression-lightgreen()

2nd expression background color lightred()

khushboo

Not applicable

Re: Color Expression on stacked bar chart based on measure

Hi Baskar,

Each Expression have some properties 

Go to expression background color of first expression->-> Background color-> Definition-> you can give required color- lightgreen()

2nd expression background color ->Definition -> lightred()

Ramya

bashar_f
Contributor

Re: Color Expression on stacked bar chart based on measure

I do have a field that both these measures are based on, its called "CDR_Status"

I put the following :-

if(CDR_Status='Success',green(),if(CDR_Status='Fail',Red()))

expression came out ok, but the barchart remains grey. Any advice?

bashar_f
Contributor

Re: Color Expression on stacked bar chart based on measure

Im sorry, but i didn't realize that I posted it in the QlikView section, I meant this for QlikSense.

Partner
Partner

Re: Color Expression on stacked bar chart based on measure

Well, it is in the QlikSense section now, I might have missed that. If so, Sorry for that.

bashar_f
Contributor

Re: Color Expression on stacked bar chart based on measure

I moved it after I replied to you

demonioazul
New Contributor III

Re: Color Expression on stacked bar chart based on measure

Bashar,

I am dealing with this colour issue as well...
I just learned that Qlik Sense 2.0 offers no way yet to change stacked bar colour with simple IF statements using multiple measures.

It is possible if you have two dimensions and one measure though. But not with one dimensions and multiple measures. Either with a drill-down dimension.


Please see my reply here:
Re: How to use custom colours in a stacked bar chart

Hope this helps,

Demian