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: 
Not applicable

Sort pie chart legend on calculated dimension

I have a calculated dimension to put records into one of four groups:

=if(PolYears >=1 and PolYears <=4, 'Insured Less Than 5 Years',

if(PolYears >=5 and PolYears <=9, 'Insured 5-9 Years',

if(PolYears >=10 and PolYears <=14, 'Insured 10-15 Years','Insured 15+ Years')))

Is there a way to sort the legend based on the value of the calculated dimension?

Insured Less than 5 Years

Insured 5-9 Years

Insured 10-15 Years

Insured >15 Years

Thanks!

Leilani

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Check the sort by expression option in the sort tab

Expression as

=if(PolYears >=1 and PolYears <=4, 1,

if(PolYears >=5 and PolYears <=9, 2,

if(PolYears >=10 and PolYears <=14, 3,4)))

Edit:

Another way is using Dual

Change your calculated dimension to

=if(PolYears >=1 and PolYears <=4, Dual('Insured Less Than 5 Years', 1),

if(PolYears >=5 and PolYears <=9, Dual('Insured 5-9 Years', 2),

if(PolYears >=10 and PolYears <=14, Dual('Insured 10-15 Years', 3),Dual('Insured 15+ Years', 4))))

Sort by number as Ascending.

Hope it helps

Celambarasan

View solution in original post

2 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Check the sort by expression option in the sort tab

Expression as

=if(PolYears >=1 and PolYears <=4, 1,

if(PolYears >=5 and PolYears <=9, 2,

if(PolYears >=10 and PolYears <=14, 3,4)))

Edit:

Another way is using Dual

Change your calculated dimension to

=if(PolYears >=1 and PolYears <=4, Dual('Insured Less Than 5 Years', 1),

if(PolYears >=5 and PolYears <=9, Dual('Insured 5-9 Years', 2),

if(PolYears >=10 and PolYears <=14, Dual('Insured 10-15 Years', 3),Dual('Insured 15+ Years', 4))))

Sort by number as Ascending.

Hope it helps

Celambarasan

Not applicable
Author

Thanks Celambarasan!

I had already tried the first method and it did not work. I cut and pasted your reply to make sure it wasn't a typo, but that also did not work. However using Dual did the trick.

Thank you so much!!

Leilani