Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a line chart where the legend is in an order which I would want to change.
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,
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
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.
An interesting way from the QV Cookbook by Stephen Redmond. I definitely recommend you to buy it :
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.
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
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
Bhawna - sorting on the expression worked thanks !
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.
Read this blog post for more information of the only() function: The Only Function