Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Dynamic Colors

Hello All

Please help me in the below query of Qlik Sense.

I want the dynamic color in my bar chart. I tried to use If condition in Color and Legend but it does not work well.

I want the first bar is of white green color and second bar is of light pink color.

Please guide me

Bar Chart.png

1 Solution

Accepted Solutions
sunny_talwar

May be you can use 2 dimensions and one expressions and then use color by expression to get this

Capture.PNG

Dimensions

Region

=ValueList('Car Sales', 'Commerical Sales')

Expression

Pick(Match(ValueList('Car Sales', 'Commerical Sales'), 'Car Sales', 'Commerical Sales'),

Sum([Car Sales]), Sum([Commerical Sales]))

Expression for color

Pick(Match(ValueList('Car Sales', 'Commerical Sales'), 'Car Sales', 'Commerical Sales'),

LightGreen(), RGB(255,182,193))

View solution in original post

7 Replies
sunny_talwar

May be you can use 2 dimensions and one expressions and then use color by expression to get this

Capture.PNG

Dimensions

Region

=ValueList('Car Sales', 'Commerical Sales')

Expression

Pick(Match(ValueList('Car Sales', 'Commerical Sales'), 'Car Sales', 'Commerical Sales'),

Sum([Car Sales]), Sum([Commerical Sales]))

Expression for color

Pick(Match(ValueList('Car Sales', 'Commerical Sales'), 'Car Sales', 'Commerical Sales'),

LightGreen(), RGB(255,182,193))

Anonymous
Not applicable
Author

Thanks a lot Sunny for help!!

Please explain Expression and Expression in Colour part.

Thanks

sunny_talwar

Hi Deepanshu -

I am not sure which part of the expression and expression in color part isn't clear? Have you used ValueList() function before? When you use valuelist, that's how your expression needs to look like. I can share a blog where you might see how ValueList is usually used:

ValueList() – For those tricky situations

In the above blog, the expression used if statement

=If(ValueList('My First KPI','My Second KPI')='My First KPI',

    Sum([My First KPI Field],

    Count([My Second KPI Field]))

But I prefer to use Pick(Match)) where ever possible. So, my version of the above expression would be

Pick(Match(ValueList('My First KPI', 'My Second KPI'), 'My First KPI', 'My Second KPI'),

    Sum([My First KPI Field],

    Count([My Second KPI Field])

Here is another useful blog that might help you learn about ValueList and ValueLoop

Missing Manual - ValueLoop() & ValueList()

its_anandrjs

Sunny, how this possible if there is date dimension on Bar chart and for maximum four dates we have to assign four different colours on bar chart and having single expression.

Any responses ???

sunny_talwar

Hey Anand, it might help to see an example to help you better my friend?

shraddha_g
Partner - Master III
Partner - Master III

if you are using latest version then you can assign Custom colors to Master Dimension Values

its_anandrjs

Hi Sunny, Assume this sample and let me know.