Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Qlik Sense - sort legend in stacked bar chart

hi all

is it possible to sort the values in the legend in a stacked bar chart in Qlik Sense.

The Stacked Bars are sorted correctly, but the legend is not.

qlik.PNG

Thank you for your support.

Kind regards

11 Replies

Re: Qlik Sense - sort legend in stacked bar chart

Probably. You might have to define the buckets in the sort order you want in the script by first creating a small table that lists the buckets in the order that you want to see. Or you can try creating the buckets as dual values using the dual() function so that each bucket has a numeric value and a textual display format. You can then sort the buckets numberically.


talk is cheap, supply exceeds demand
Not applicable

Re: Qlik Sense - sort legend in stacked bar chart

hi

thanks for you reply. I have already created the small sorting table (I use it to sort the categories in the stacked chart), but for some reason the legend does not sort like the stack charts.

table script:

[Sort]:

LOAD * INLINE

[

rank, "Bucket - Days Late"

1,'0'

2,'1 to 30'

3,'31 to 90'

4,'91 to 180'

5,'181 to 360'

6,'361 or more'

];

Re: Qlik Sense - sort legend in stacked bar chart

To be honest the legend looks ok to me. I don't see what's wrong with it. Can you post a small qlik sense app that shows the problem?


talk is cheap, supply exceeds demand
MVP
MVP

Re: Qlik Sense - sort legend in stacked bar chart

Move the dimension bucket to the first position in Sorting.

- Ralf

MVP
MVP

Re: Qlik Sense - sort legend in stacked bar chart

Oh no, this isn't possible. So, I think it's an issue then..

joydipp1988
Contributor

Re: Qlik Sense - sort legend in stacked bar chart

Hi Jernej,

Hope everything is fine. As per your requirement below is my solution.

//--------------------------- Script for Bucket generation ---------------------------//

Bucket_Dimension:

LOAD

     Dual('1 to 30',1) as Bucket

Autogenerate 1;

LOAD

     Dual('31 to 90',2) as Bucket

Autogenerate 1;

LOAD

     Dual('91 to 180',3) as Bucket

Autogenerate 1;

LOAD

     Dual('181 to 360',4) as Bucket

Autogenerate 1;

LOAD

     Dual('360 to above',5) as Bucket

Autogenerate 1;

//--------------------------------------- End of code ---------------------------------------//

The Bucket_Dimension will be created as a Data Island with only one field in it. Now you can use Bucket field as dimension in your chart and your legend will automatically be sorted and no additional setup will be needed.

Hope that helps. If you find this answer as useful then please mark it as Answered.


Regards,

Joy

rvijayanth
New Contributor III

Re: Qlik Sense - sort legend in stacked bar chart

In legend, the values are not in ascending order.

melindabardess
New Contributor

Re: Qlik Sense - sort legend in stacked bar chart

Hi all,  has anyone found a resolution or a workaround for the legend sorting issue that works?  I am running into the same exact issue.  I am also using the Limitation property to get the top 10 dimension values and the sorting between the stacked bar chart and legend is not working or matching.

Best,

MB

shraddha_g
Honored Contributor III

Re: Qlik Sense - sort legend in stacked bar chart

You can use pick () for sorting.

Ex. pick(Wildmatch(FieldName,'Value1','Value2','Value3'),1,2,3)

Community Browser