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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
ashmitp869
Creator II
Creator II

sort with age group used as dimension

Hi all,

I want to order by Age Group : 

agebr.PNG

 

My script:

LOAD
[Age],
if(Age<=50 ,'Age Below 50',
if(Age>=50 and Age<=59 ,'Between 50-59',
if(Age>=60 and Age<=69 ,'Between 60-69',
if(Age>=70 and Age<=79 ,'Between 70-79',
if(Age>=80 and Age<=89 ,'Between 80-89',
if(Age>90 ,'Above 90','Other'
)))))) as [Age Group]
ResidentPATIENT;

 

 

1 Solution

Accepted Solutions
MayilVahanan

Hi @ashmitp869 

Try like Dual() function & sort by numeric

LOAD
[Age],
if(Age<=50 , Dual('Age Below 50',1),
if(Age>=50 and Age<=59 ,Dual('Between 50-59',2),
if(Age>=60 and Age<=69 , Dual('Between 60-69',3),
if(Age>=70 and Age<=79 ,Dual('Between 70-79',4),
if(Age>=80 and Age<=89 ,Dual('Between 80-89',5),
if(Age>90 ,Dual('Above 90',6), Dual('Other',7)
)))))) as [Age Group]
ResidentPATIENT;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

2 Replies
MayilVahanan

Hi @ashmitp869 

Try like Dual() function & sort by numeric

LOAD
[Age],
if(Age<=50 , Dual('Age Below 50',1),
if(Age>=50 and Age<=59 ,Dual('Between 50-59',2),
if(Age>=60 and Age<=69 , Dual('Between 60-69',3),
if(Age>=70 and Age<=79 ,Dual('Between 70-79',4),
if(Age>=80 and Age<=89 ,Dual('Between 80-89',5),
if(Age>90 ,Dual('Above 90',6), Dual('Other',7)
)))))) as [Age Group]
ResidentPATIENT;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
avinashelite

You could also create a simple inline table also and achieve

 

Load * Inline

[

Age Group,Age_Group_Sort

'Age Below 50',1
'Between 50-59',2
'Between 60-69',3

'Between 70-79',4
'Between 80-89',5
'Above 90',6

'Other',7

];

 

 

Use Age_Group_Sort in the sorting