3 Replies Latest reply: Oct 8, 2016 7:27 AM by Sunny Talwar RSS

    Dynamic Colors

    Deepanshu Chamoli

      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

        • Re: Dynamic Colors
          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))

            • Re: Dynamic Colors
              Deepanshu Chamoli

              Thanks a lot Sunny for help!!

               

              Please explain Expression and Expression in Colour part.

               

              Thanks

                • Re: Dynamic Colors
                  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()