Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Multilevel sort on bar chart

Hi Experts,

This may look like a simple task but I can't seem to do it properly. Most of the materials I've found so far here are on custom sorts, but nothing on multilevel sort. Essentially, I want my bar chart to sort first by Country (Descending A>Z) then by Value (Descending).

Sample table below and I have attached the qvw file with the bar chart.

LocationCountryValue
AAUSA150
BBCanada500
CCUSA250
DDCanada400
EEUSA300
FFCanada1000

Hoping for any advice. Thanks!

15 Replies
florentina_doga
Partner - Creator III
Partner - Creator III

try this

Anonymous
Not applicable
Author

Good approach and considered this earlier. I failed to mention that I can't change the look and feel of the chart. X-axis should always just be the Location.

sunny_talwar

How about this for the sorting expression:

Ord(Country) * 10000 - Sum(Value)

Giving higher weight to Country by multiplying it by 10000 and then subtracting Sum(Value)

The number to be multiplied with will depend on the max value of Sum(Value). You would want the 10,000 in my example to be bigger than the max value of Sum(Value). In our case the max was 1000 so I randomly picked 10000. But if in your actual scenario the max(value) is 600000000, I would multiply by 1000000000.

Capture.PNG

I guess a better image with slight modification of data

Capture.PNG

Kushal_Chawda

You can try the way suggested by others as alternative. But doing so in script will keep the things well structured rather than going for complex expressions.

Anonymous
Not applicable
Author

according to the sort tab we can sort is possible

tamilarasu
Champion
Champion

Yes. I didn't notice it properly. You can use Sunny's solution. But you no need to enter the multiplied value manually. Instead you can use below expression.

Ord(Country) * Max(Total Aggr(Sum(Value),Location)) - Sum(Value)