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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Krish2459_58
Creator II
Creator II

Sorting

Hi,

 I need to sort the below column from  -ve to +ve.  Attaching the sample file. Please suggest.

-0 to -50
0 to 1,000
20,001 to 40,000
5,001 to 10,000
1,001 to 5,000
-51 to -100
No change
-100 to -200
10,001 to 20,000
-501 to -1,000
-201 to -500
40,000 to 60,000
60,001 +
-1,001 +
Labels (1)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

As below

Load Grouping,new_grouping,recno() as rown, Coalesce(subfield(new_grouping,'to',2),trim(new_grouping),0) as sort_order 
;
Load Grouping, trim(replace(replace(replace(Grouping,'+',''),',',''),'No change',0)) as new_grouping
inline [
Grouping
"-0 to -50"
"0 to 1,000"
"20,001 to 40,000"
"5,001 to 10,000"
"1,001 to 5,000"
"-51 to -100"
"No change"
"-100 to -200"
"10,001 to 20,000"
"-501 to -1,000"
"-201 to -500"
"40,000 to 60,000"
"60,001 +"
"-1,001 +"
];
exit Script;

 

Then use the sort_order field as Sort By Expression

=Max(sort_order)

vinieme12_0-1690453344632.png

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

1 Reply
vinieme12
Champion III
Champion III

As below

Load Grouping,new_grouping,recno() as rown, Coalesce(subfield(new_grouping,'to',2),trim(new_grouping),0) as sort_order 
;
Load Grouping, trim(replace(replace(replace(Grouping,'+',''),',',''),'No change',0)) as new_grouping
inline [
Grouping
"-0 to -50"
"0 to 1,000"
"20,001 to 40,000"
"5,001 to 10,000"
"1,001 to 5,000"
"-51 to -100"
"No change"
"-100 to -200"
"10,001 to 20,000"
"-501 to -1,000"
"-201 to -500"
"40,000 to 60,000"
"60,001 +"
"-1,001 +"
];
exit Script;

 

Then use the sort_order field as Sort By Expression

=Max(sort_order)

vinieme12_0-1690453344632.png

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.