Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Welcome to Qlik Community! Check out our new navigation! FIND OUT MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
GillBech
Contributor II
Contributor II

Bar Chart - 2 measures / How to set colors per measure ?

Hi 

I created a bar chart / To compare each month of two years that I select.
I set 2 measures : 1 by year.
And for each month , I check if it's Year to date (YTD) or year to go (YTG).

If I base color formula on YTD/YTG then I can have 2 different colors. But if I want to set different colors for each mesur then I don't succeed.

This is what I would like to get (light blue and light red for year to date / blue and red for ytg) : 

Image1.png

This is what I get when color is only taking yTD/YTG  (=if(Col_YTDYTG='YTD',rgb(148,180,212),rgb(68,119,170))Image2.png

This is what I get when I try a condition based on year : $(V_BaseYear) = 2019 / $(V_ComparedYear) = 2021
=if(Col_Year=$(V_BaseYear),
if(Col_YTDYTG='YTD',rgb(225,163,173),rgb(204,102,119)),
if(Col_Year=$(V_ComparedYear),
if(Col_YTDYTG='YTD',rgb(148,180,212),rgb(68,119,170))
))

Image3.png

Thanks for your help

I posted a sample qs and data file

 

 

 

1 Solution

Accepted Solutions
GillBech
Contributor II
Contributor II
Author

2 Replies
Sammy_AK
Creator II
Creator II

i see that you have used a combo chart, instead you need to use a Bar chart. Add 2 dimensions i.e. col_month & col_year and one measure which is $(vBaseYear) + $(vComparedYear). in the colors and legend option you can input your color expression to achieve your desired output. i have also attached the QVF file for your reference

if(Col_Year=$(V_BaseYear),
if(Col_YTDYTG='YTD',$(C_ComparedYTD_Color),$(C_ComparedYTG_Color)),
if(Col_Year=$(V_ComparedYear),
if(Col_YTDYTG='YTD',$(C_BaseYTD_Color),$(C_BaseYTG_Color))
))

GillBech
Contributor II
Contributor II
Author

Thanks a lot @Sammy_AK