15 Replies Latest reply: Mar 27, 2015 8:30 AM by durga seelam

# 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

• ###### 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

• ###### 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))

• ###### 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];

• ###### 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

• ###### 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'))

• ###### 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

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

can you post example qvw?

• ###### 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.

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

Ruben, I am implemented as above only, may be due to caliculated dimension it is not giving correct output.

i am getting correct order in listbox but not getting in dimension legend for piechart.

Thanks,

Durga

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

Hi durga, can you check in the sort tab if the dimension is sorted by number (not alphabetical)

Manish, Rudolf and Rupas solutions also should work, so it can be something to do with calculated dimension or other options messing, but without a sample is hard to guess, please upload a sample.

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

Hi Durga,

Add a sorting below sorting table.

SortingTable:

dayscheck, Sort

0-10 Days,1

11-30 Days,2

31-50 Days,3

51-70 Days,4

70+ Days,5];

and then added Sort Field in the Expression as shown in the screen shot.

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

Rupas,

I have already written below script in edit script to get "dayscheck" field, so how can i change to your way to call variable 'sort' in expression tab.

Details:
if(length <= 10, Dual('0-10 Days',1),
if(length <= 30, Dual('11-30 Days',2),
if(length <= 50, Dual('31-50 Days',3),
if(length <= 70, Dual('51-70 Days',4),Dual('70+ Days',5))))) as dayscheck

resident temp;
drop table temp;

Thanks,

Durga

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

Hi, and paste a screenshot of the sort tab?

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

Ruben, when i click on numeric order it diplayed correctly.

Rupes wonderful explination.

Manish/ Rudolf thank you very much for all your support!

Thanks a ton for all!

Durga.