Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
bashar_f
Partner - Creator
Partner - Creator

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?



19 Replies
Anonymous
Not applicable

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

stigchel
Partner - Master
Partner - Master

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

Hi,

Go to background color of first expression-lightgreen()

2nd expression background color lightred()

khushboo

Not applicable

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
Partner - Creator
Partner - Creator
Author

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
Partner - Creator
Partner - Creator
Author

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

stigchel
Partner - Master
Partner - Master

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

bashar_f
Partner - Creator
Partner - Creator
Author

I moved it after I replied to you

demonioazul
Creator
Creator

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