19 Replies Latest reply: Aug 29, 2017 11:12 PM by Gus Feltham RSS

    Qlik Sense bar chart legend sort required

    Gus Feltham

      I'm having trouble getting the legend to sort in the same way the data is for a chart:

      my load script includes dual function as below:

          IF("Est Vehicle speed during incident"='0-25 km',dual('0-25km/h',1),

          IF("Est Vehicle speed during incident"='25-50 km',dual('25-50km/h',2),

              IF("Est Vehicle speed during incident"='50-75 km',dual('50-75km/h',3),

              IF("Est Vehicle speed during incident"='75-100 km',dual('75-100km/h',4),

              IF("Est Vehicle speed during incident"='100-130 km',dual('100-130km/h',5))))))


      however the legend always shows with '75-100km/h' and '50-75km/h' in the wrong order i.e. I want ascending and the other values do show correctly in ascending order - I have it set under sorting to numerical/ascending. 

      The chart has a month dimension, and then the dimension above.  The only measure is a count of ID's to get number of instances..

      Please advise on options to try for this.  Thanks.

        • Re: Qlik Sense bar chart legend sort required
          Devarasu R


          Can you try like this?

          Pick(Wildmatch([Est Vehicle speed during incident],'0-25 km','25-50 km','50-75 km','75-100 km','100-130 km','*'),




          • Re: Qlik Sense bar chart legend sort required
            Fei Xu

            I have seen many people (including myself) that had this problem. So in the bar / line charts, if there are two dimensions, the first dimension can be sorted correctly but for the second dimension, sometimes it does not work right! My previous workaround is always try to avoid using two dimensions, try to make the second dimension to the expression.


            For example, in your case, remove the second dimension and make five expressions for each speed category.


            For the original app you have attached, if I opened it using the latest Sense version (June 2017 Patch one), I could see the "75-100km/h" was in front of 50-75, which was not right. However if I go to the "Colour and Legend" in the Appearance, uncheck the "Show Legend Title" box, then 50-75 jump into the front of 75-100.


            It looks to me that the problem is solved in June 2017 Patch 1. I then went back to the released notes and found the following bug fixed at page 9:




            Can you try the same thing again using June 2017 Patch one? I hope that Qlik has fixed this because it is annoy and when client asks why this happens, I don't know how to reply.





            • Re: Qlik Sense bar chart legend sort required
              Jacek Stypulkowski

              Hi Gus,


              please set up the Colours and legend by your "Speed" dimension then the legend will sort as you expect.