Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
agardoge
Contributor II
Contributor II

Sorting Legend for a Bar Chart

Hi! I am trying to sort a legend in a bar chart by descending year, and currently the order is not correct. For the year, it is extracted from a field called Move.Date which is formatted as "MM/DD/YYYY" so for example "01/09/2023". I extracted it by setting under Field: "=Year([Move.Date])".  I am fairly new to Qlik so any help would be appreciated! Legend.png

 

Labels (1)
1 Solution

Accepted Solutions
QFabian
Specialist III
Specialist III

first sort by "Description" as alphabetically

second sort by Year as number

legend color set to "By Dimension"  by Year 

QFabian

View solution in original post

8 Replies
QFabian
Specialist III
Specialist III

Hi @agardoge check if this configuration works, when you have to order by a specific field, let the other fields order by  load

QFabian_0-1673313144628.png

QFabian_1-1673313203872.png

 

QFabian
agardoge
Contributor II
Contributor II
Author

@QFabian thanks for the suggestion.  So my bar chart, under each bin called "Description", there is a value based on the year. So for example, the number of Apples collected in 2019 through 2023 is shown then the number of oranges, etc. So I would like to still sort the bins alphabetically - in the below picture, showing 8L then 12L then 30L then 33L, etc. Is there a way to do this? Because using your suggestion, it fixes the legend but then the bin order changes. 

Legend.png

QFabian
Specialist III
Specialist III

Hi @agardoge , please check if this works for you :

With 'Automatic' in Colors :

QFabian_0-1673365152486.png

With Custom Colors  and By Dimension:

QFabian_1-1673365207117.png

 

QFabian
agardoge
Contributor II
Contributor II
Author

@QFabian It's getting closer, thanks for the suggestion! The only issue that is left is that while the legend is now sorted and the correct order of the bins is there, the years that were added to the X-axis are not in order. Is there a way to order the bars? So far, I sorted the "Description" to sort alphabetically, Year is Automatic, and for the legend the color is set to "By Dimension". 

Legend.png

QFabian
Specialist III
Specialist III

first sort by "Description" as alphabetically

second sort by Year as number

legend color set to "By Dimension"  by Year 

QFabian
agardoge
Contributor II
Contributor II
Author

@QFabian When I try the above, using the sort for the Year as a number, it only changed a few of them but I had to also remove all sorting from Count(Description). 

 

Legend.png

agardoge
Contributor II
Contributor II
Author

UPDATE:

When I uncheck "Include Null Values" and set sort for Year to "Auto" it partially fixes it for some of the bins but not others. 

agardoge_1-1673461616170.png

 

 

QFabian
Specialist III
Specialist III

@agardoge could be seems to be not ordered because there is no data for every Descripcion/Year, so there are less columns in some cases

QFabian