Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! 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
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

Hi Sangram,

I want to color a stacked chart which is having "department name" as dimension and "Count(users), Count(divisions)" as measures.

I have tried doing it in color expression editor but no use.

Could you suggest me the way to do it?

Awaiting.

mgranillo
Specialist
Specialist

Sravanthi,

Does Sangram's solution work?  If yes, can you mark the answer as correct?

Not applicable

No, It din't. I am just waiting for his reply.

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

That is the current available solution. Sangram's answer should be marked as correct.

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Not applicable

I am unable to get it for the condition I have given above, could u pls suggest on my query

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi


Please Attach qvf file and we will get it working

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
adandreti
Contributor II
Contributor II

Hello,

This solution works for me thanks, but now I am having a hard time sorting the way I would like. I was wondering if anyone could inform me on how to sort numerically descending based on the second value represented in my value list while deploying this color scheme? I have tried a couple "sort by expression's" but non give me the desired result.

Thx

adandreti
Contributor II
Contributor II

One way to achieve this is by creating a Master Item Measure for both of your measures. In creation of this measure you are able to select the color of your choice for each respective measure. Note that these colors will stay consistent throughout your app if you have them displayed in multiple sheets.

ab9503
Contributor II
Contributor II

@adandreti, thank you for that!!