Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

Line chart - Custom Legend order

Hello,

I have a line chart where the legend is in an order which I would want to change.

chart leged.png

If you notice though Stream 2 (orange line) is on the top whereas Stream 1 (blue) is way below.

I want to sort the legend based on the order in which the chart appears

So my legend would be

Stream 2

Stream 3

Stream 6

Stream 5

Stream 4

Stream 1

How do I achieve this ?

Thanks,

13 Replies
SunilChauhan
Esteemed Contributor

Re: Line chart - Custom Legend order

i thing its depends upon value you have in data. so its not passiable

the values range from 0-300 in case and blue value is near by zero.

thats why looking as above

hope this helps

MVP & Luminary
MVP & Luminary

Re: Line chart - Custom Legend order

Edit the group you defined. On the Group Settings window click on the Sort Orders button. Then select the dimension of the group you want to sort. Choose to sort by Expression. Use an expression like: =match(only({1} MyStreamDimension), 'Stream 2','Stream 3','Stream 6','Stream 5','Stream 4','Stream 1'). Replace MyStreamDimension with the name of the dimension you want to sort.


talk is cheap, supply exceeds demand
Partner
Partner

Re: Line chart - Custom Legend order

An interesting way from the QV Cookbook by Stephen Redmond. I definitely recommend you to buy it :

CookBook.jpg

Not applicable

Re: Line chart - Custom Legend order

you can sort your values which show first but line positioning can not be changed,because it is defined by values,

you can sort your line by giving the expression.

Not applicable

Re: Line chart - Custom Legend order

Hello Gysbert,

Can you explain how this will work - my stream dimension will grow and is not only limited to the 6 streams.

Also, how will this help to order the legend in terms of value - today maybe stream 2 is on the top - but tomorrow it might be stream 6.

TIA

Not applicable

Re: Line chart - Custom Legend order

Hello Ioannis,

I use this when I have only one dimension, in this case its a cyclic group and when I use

Dual(If([Month Year]=Max(total[Month Year]),(cyc_ProStr) ,' '),my expression))  where cyc_ProStr is the name of my cyclic group  - It doesn't work

Not applicable

Re: Line chart - Custom Legend order

Bhawna - sorting on the expression worked thanks !

Not applicable

Re: Line chart - Custom Legend order

Hello,

I'm also trying to figure out how to customize the order of my legend as I don't want it to automatically sort in asc or desc order.

I'm trying to understand how the expression works. I found the documentation in help file for the "match" function but I don't understand what the "only({1} MyStreamDimension)" part of your expression does. Is "only" a function? I couldn't find it in the documentation.

Could you please elaborate?

Thanks.

MVP & Luminary
MVP & Luminary

Re: Line chart - Custom Legend order

Read this blog post for more information of the only() function: The Only Function


talk is cheap, supply exceeds demand