Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

scheibercamo
New Contributor II

How do you sort names within a field into order for a chart?

I have 13,000 items that belong to one of the following age bands. I want them to appear in a bar chart (measuring some other value) but in the following order:

Age Band

Past due > 360 days
Past due 181 - 360 days
Past due 91 - 180 days
Past due 61 - 90 days
Past due 31 - 60 days
Past due 1 - 30 days
Due 0 - 30 days
Due 31 - 60 days
Due 61 - 90 days
Due > 90 days

When I tried:

match([Age Band]),'Past due>360 days','Past due - 360 days','Past due 91 -180 days','Past due 61 -90 days','Past due 31 - 60 days','Past due 1 - 30 days','Due 0 - 30 days','Due 31 - 60 days','Due 61 -90 days','Due>90 days')

It didn't work. Thanks for your help in advance.

1 Solution

Accepted Solutions
shivkumar300
New Contributor III

Re: How do you sort names within a field into order for a chart?

Hi,

use this code in sort by expression

=if([Age Band]='Past due > 360 days','1',  if([Age Band]='Past due 181 - 360 days','2',  if([Age Band]='Past due 91 - 180 days','3',  if([Age Band]='Past due 61 - 90 days','4',  if([Age Band]='Past due 31 - 60 days','5',  if([Age Band]='Past due 1 - 30 days','6',  if([Age Band]='Due 0 - 30 days','7',  if([Age Band]='Due 31 - 60 days','8',  if([Age Band]='Due 61 - 90 days','9',10  )))))))))

in other way you can do it by creating a new field in your script

=if([Age Band]='Past due > 360 days','1',  if([Age Band]='Past due 181 - 360 days','2',  if([Age Band]='Past due 91 - 180 days','3',  if([Age Band]='Past due 61 - 90 days','4',  if([Age Band]='Past due 31 - 60 days','5',  if([Age Band]='Past due 1 - 30 days','6',  if([Age Band]='Due 0 - 30 days','7',  if([Age Band]='Due 31 - 60 days','8',  if([Age Band]='Due 61 - 90 days','9',10  ))))))))) as Sort

then do sorting according to sort field in sort by expression 

8 Replies
MVP
MVP

Re: How do you sort names within a field into order for a chart?

Are you creating these bands in the script? If you are, then create them using Dual function so that you can provide them a sorting value

scheibercamo
New Contributor II

Re: How do you sort names within a field into order for a chart?

Hey Sunny! No, I added them later under sorting as an expression for that value.

How do I create them using dual function?

MVP
MVP

Re: How do you sort names within a field into order for a chart?

Can you share your current expression?

scheibercamo
New Contributor II

Re: How do you sort names within a field into order for a chart?

match([Age Band],'Past due > 360 days','Past due 181 - 360 days','Past due 91 - 180 days','Past due 61 - 90 days','Past due 31 - 60 days','Past due 1 - 30 days','Due 0 - 30 days','Due 31 - 60 days','Due 61 - 90 days','Due > 90 days')

I actually tried it again and it seemed to work, but only when I start typing "Age Band" and I select it from the drop-down.

Even though my issue is solved I'd like to know what that is.

Not applicable

Re: How do you sort names within a field into order for a chart?

jaimeaguilar
Valued Contributor II

Re: How do you sort names within a field into order for a chart?

HI,

maybe if you try with pick(match)), something like this:

pick(match([Age Band],'Past due > 360 days','Past due 181 - 360 days'), 1, 2) and so on...

regards

shivkumar300
New Contributor III

Re: How do you sort names within a field into order for a chart?

Hi,

use this code in sort by expression

=if([Age Band]='Past due > 360 days','1',  if([Age Band]='Past due 181 - 360 days','2',  if([Age Band]='Past due 91 - 180 days','3',  if([Age Band]='Past due 61 - 90 days','4',  if([Age Band]='Past due 31 - 60 days','5',  if([Age Band]='Past due 1 - 30 days','6',  if([Age Band]='Due 0 - 30 days','7',  if([Age Band]='Due 31 - 60 days','8',  if([Age Band]='Due 61 - 90 days','9',10  )))))))))

in other way you can do it by creating a new field in your script

=if([Age Band]='Past due > 360 days','1',  if([Age Band]='Past due 181 - 360 days','2',  if([Age Band]='Past due 91 - 180 days','3',  if([Age Band]='Past due 61 - 90 days','4',  if([Age Band]='Past due 31 - 60 days','5',  if([Age Band]='Past due 1 - 30 days','6',  if([Age Band]='Due 0 - 30 days','7',  if([Age Band]='Due 31 - 60 days','8',  if([Age Band]='Due 61 - 90 days','9',10  ))))))))) as Sort

then do sorting according to sort field in sort by expression 

MVP
MVP

Re: How do you sort names within a field into order for a chart?

May be because of extra spaces between Age and Band... Difficult to say much without seeing your app...