Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
joshakehurst
Partner - Contributor III
Partner - Contributor III

Add color expression to Bar Chart

I'm trying to implement specific colors to a Bar chart which is binned using a dual expression as a dimension.  The expression to create the dimension is listed below and I'm using an measure to count the number of records.  I would like to apply a different RGB color (Green / Yellow / Red) to each bin in the below chart, but nothing is working to add a color as an expression. 

If(Ratio<=.2, Dual('0-20%',2),

     If(Ratio<=.3, Dual('20-30%',4),

     If(Ratio<=.4, Dual('30-40%',6),

     If(Ratio<=.5, Dual('40-50%',8),

     If(Ratio<=.6, Dual('50-60%',10),

     If(Ratio<=.7, Dual('60-70%',30),

     IF(Ratio <= .8, Dual('70-80%',40),

     Dual('80%+',50))))))))

Screen Shot 2017-05-18 at 11.17.00 AM.png

1 Solution

Accepted Solutions
sunny_talwar

Try this

If(Max(Ratio)<=.2, LightMagenta(),

    If(Max(Ratio)<=.3, Blue(),

    If(Max(Ratio)<=.4, Green(),

    If(Max(Ratio)<=.5, Red(),

    If(Max(Ratio)<=.6, LightGray(),

    If(Max(Ratio)<=.7, Brown(),

    IF(Max(Ratio) <= .8, Yellow(),

    LightCyan())))))))


Capture.PNG

View solution in original post

6 Replies
sunny_talwar

Something like this in the background color for the expression isn't working?

If(Ratio<=.2, LightRed(),

     If(Ratio<=.3, Blue(),

     If(Ratio<=.4, Green(),

     If(Ratio<=.5, Color4,

     If(Ratio<=.6, Color5,

     If(Ratio<=.7, Color6,

     IF(Ratio <= .8, Color7,

     Color8)))))))

joshakehurst
Partner - Contributor III
Partner - Contributor III
Author

Yeah that was my exact thought, but whenever I apply this approach to the color expression every bar is grey like the example screenshot.  Perhaps I need to bin the data differently and not use the dual method as the dimension?  I'm not sure how else to custom bin the data in the bar chart.

sunny_talwar

Try this

If(Max(Ratio)<=.2, LightMagenta(),

    If(Max(Ratio)<=.3, Blue(),

    If(Max(Ratio)<=.4, Green(),

    If(Max(Ratio)<=.5, Red(),

    If(Max(Ratio)<=.6, LightGray(),

    If(Max(Ratio)<=.7, Brown(),

    IF(Max(Ratio) <= .8, Yellow(),

    LightCyan())))))))


Capture.PNG

Anil_Babu_Samineni

Can you share sample application, Seems you are taking Dimension as Color, May be try the same in Expression BG Color

Best Anil, 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
joshakehurst
Partner - Contributor III
Partner - Contributor III
Author

Yep - adding the Max function worked.  Thanks for the tip. 

prudhviqlik
Contributor
Contributor

how can it work on max function, tell me in this situation