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!

1 Solution

Accepted Solutions
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)

View solution in original post

15 Replies
Chanty4u
MVP
MVP

is this?

Anonymous
Not applicable
Author

Hi Chanty, in your file, the bars are sorted by Country but they are not sorted by Value as a secondary sort. The final look of the graph would have the bars in this order:

FF (Canada-1000) - BB (Canada-500) - DD (Canada-400) - EE (USA-300) - CC (USA-250) - AA (USA-150)

Kushal_Chawda

can you try this

First create the Sort Table

Sort:

LOAD distinct Country,

           Autonumber(Country) as SortCountry

Resident YourTable

Order by Country desc;

Now go to chart Properties-Sort Tab-> Check expression -> Descending put below condition

=SortCountry & YourExpression

zhadrakas
Specialist II
Specialist II

Hello Mark,

Go to Chart Properties -> Sort Tab

- Make sure the Sort list is right (1st Country, 2nd Value)

- Sort Country A-Z

- Sort Value Numeric Descending

tamilarasu
Champion
Champion

Hi Mark,

Try sort expression as


=Sum(Value)&Ord(Location)

Capture.PNG

Attached the updated file.

florentina_doga
Partner - Creator III
Partner - Creator III

maybe this ! !

Anonymous
Not applicable
Author

This actually achieved the desired sort order by chance. But it is not working well. For one thing, the expression does not consider the Country.

It should sort by Country first

THEN

sort by Sum(Value)

Anonymous
Not applicable
Author

Yes, the straight table you have is correctly sorted into the desired order but how do you translate that same order onto the bar graph?

Anonymous
Not applicable
Author

Tried and yes this looks good! Quick question, is there an alternative way of achieving this from within the bar chart only and without having to use the Load Script?