9 Replies Latest reply: Feb 22, 2017 6:27 PM by Petter Skjolden RSS

    Coloured the line chart

    Giulio Andrea Toscano

      Hi,

       

      Is it possible to set something by expression that allows me to view the chart colour based on the rank?

      For example I always want that the highest line in the chart has always blue colour, the second yellow, the third black and so on...

       

      My line chart it is a standard Line chart based on 2 dimensions Date and Product Name and one measure Sales.

       

      The dimension Product Name has the following expression:

      If(

        Aggr({<Date={">=$(=Num(Today() - 11))"}>} Rank(Sum(Sales)) , [Product Name])<=10 ,

        [Product Name]

      )

       

      Any help will be really appreciated.

       

      Thanks,

       

      Giulio

        • Re: Coloured the line chart
          Petter Skjolden

          Something like this might work well for you ....

           

          2017-02-20 19_12_44-Qlik Sense Desktop.png

           

           

          Just be aware of adjusting the Rank()-function with the right parameters so you get a unique ranking or you might get two or more lines with the same color. There is a shared ranking that is default I think....

            • Re: Coloured the line chart
              Giulio Andrea Toscano

              Hi Petter,

               

              Thank you very much for your solution, but doesn't work in my graph because I don't have the lines as separated as yours. Other than that my dimension is set in order to display the best 10 product in the last 10 days, but the chart display data start from 2015 (so I could not use the rank function as I have written for my Product dimension.

               

              I have tried with 2 function:

              pick(rank(aggr(Sum(Sales),[Product name],Date)),red(),green(),yellow(),black(),White())

              and pick(rank(Sum(Sales)),red(),green(),yellow(),black(),White()), but the result is the same (see the image).

              I want that the colour will be consistent across the different dimension (Product name).

              If I aggregate only per [Product name] the chart will be coloured only in one point per line. I could not reproduce this logic in tables I have tried so many times. The fact is that I want to coloured a dimension by using the ranking expression, but doesn't work.

               

              Chart.PNG !