# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for
Did you mean:
Highlighted
Contributor III

## 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
Highlighted
Contributor III

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
Highlighted
MVP

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

Highlighted
Contributor III

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

How do I create them using dual function?

Highlighted
MVP

Can you share your current expression?

Highlighted
Contributor III

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.

Highlighted
Not applicable
Highlighted
Partner

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

Highlighted
Contributor III

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

Highlighted
MVP

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