# QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Announcements
QlikView Fans! We’d love to hear from you.
Rules, plus terms and conditions, can be found here.
Contributor

## Help me in sorting the order of legend?

Hi All,

I have one field dayscheck as below

dayscheck

0-10 Days

11-30 Days

31-50 Days

51-70 Days

70+ Days

I used the above dayscheck field in my caliculated dimension.

=if(wildmatch(Billing,'pending','approved','Dues','Verified','Closed'),dayscheck)

Now problem is with legend. It is diplaying the order in below way,

I am unable to sort the order  Can anyone please help me to sort the order in legend.

Thanks, Durga

Tags (1)
1 Solution

Accepted Solutions
Highlighted
MVP

## Re: Help me in sorting the order of legend?

Hi durga, I usually create the buckets using dual function, so the values are a number with a text representation, in script you can create dayscheck like this:

If....., Dual('0-10 Days', 1),

If(...., Dual('11-30 Days', 2)... and so on

This way the text is related to a number and they can be sorted easily, usually they are automatically sorted using the number.

15 Replies
MVP

MVP

## Re: Help me in sorting the order of legend?

Go to sort tab and under expression write below

=Only({1}Pick(Match(dayscheck,'0-10 Days','11-30 Days','31-50 Days','51-70 Days','70+ Days'),1,2,3,4,5))

New Contributor III

## Re: Help me in sorting the order of legend?

You can also use Load Order sorting. Just put this this inline table at the begin of your script and drop it at the end.

SortingTable:

dayscheck

0-10 Days

11-30 Days

31-50 Days

51-70 Days

70+ Days];

Honored Contributor

## Re: Help me in sorting the order of legend?

i have a shorter solution:

goto sort tab and define

=num(left(dayscheck,1)

and sort ascending

Expression will get 0,1,3,5, 7 and that should be all you need

Contributor

## Re: Help me in sorting the order of legend?

Hi Robert,

Thanks for response!  I followed the same as in that link but it is not sorting the legend values. again it is showing the order as in screenshot.

Thanks,

durga

MVP

## Re: Help me in sorting the order of legend?

=Only({1}Match(dayscheck,'0-10 Days','11-30 Days','31-50 Days','51-70 Days','70+ Days'))

Highlighted
MVP

## Re: Help me in sorting the order of legend?

Hi durga, I usually create the buckets using dual function, so the values are a number with a text representation, in script you can create dayscheck like this:

If....., Dual('0-10 Days', 1),

If(...., Dual('11-30 Days', 2)... and so on

This way the text is related to a number and they can be sorted easily, usually they are automatically sorted using the number.

Contributor

## Re: Help me in sorting the order of legend?

Hi Rudolf/Manish,

I have calicuated dimension in pie chart  as below:

=if(wildmatch(Billing,'pending','approved','Dues','Verified','Closed'),dayscheck)

Now my dimension label name is status, if i go to sort tab it is showing status dimension, i write condition as you said but it is not changing the dimension order.

@ Manish: how can i write set expression for dayscheck in calicualted dimension.

same clumsy order is displaying in legend as above screenshot.

Thanks,

Durga

Honored Contributor

## Re: Help me in sorting the order of legend?

can you post example qvw?