Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

deepanshu_chamo1
New Contributor

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
MVP
MVP

Re: Dynamic Colors

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

7 Replies
MVP
MVP

Re: Dynamic Colors

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

deepanshu_chamo1
New Contributor

Re: Dynamic Colors

Thanks a lot Sunny for help!!

Please explain Expression and Expression in Colour part.

Thanks

MVP
MVP

Re: Dynamic Colors

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

Re: Dynamic Colors

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 ???

MVP
MVP

Re: Dynamic Colors

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

shraddha_g
Honored Contributor III

Re: Dynamic Colors

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

Re: Dynamic Colors

Hi Sunny, Assume this sample and let me know.

Community Browser