Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sort Expression

I have a dimension of Name, and this will only ever contain 4 names. It is set in stone.

I do not want to order in alphabetical order, either ascending or descending. I need to order specifically.

e.g. B,A,Z,Y

How can I do this with an expression?

6 Replies
sushil353
Master II
Master II

go to sort tab and in expression:

if(NAME='B',1,if(NAME='A',2,if(NAME='Z',3,4)))

HTH

Sushil

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     There are two ways you can do this.

     1. Define the sorting in Script :-

          Create a table which is link to your table with sort order. Something like below.

          Data:

          Load Name from Abc;

    

          Sorting:

          Load * inline [

          Name, Sorting

          B,1

          A,2

          Z,3    

          Y,4

          ];

          Then in sort window click on the expression and type the field name as Sorting.

         2. IN expression it self.

               Some thing like this.

               if(Name = 'B',1,

                    if(Name = 'A',2,

                         if(Name = 'Z',3,

                                if(Name = 'y',4))))  

              

     Hope this is clear.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

use in the sort tab the following expression:

=match(Name,'B','A','Z','Y')

jagan
Luminary Alumni
Luminary Alumni

Hi,

If you have lot of values then following Koushik's first solution

1. Define the sorting in Script :-

          Create a table which is link to your table with sort order. Something like below.

          Data:

          Load Name from Abc;

    

          Sorting:

          Load *

          inline [

          Name, Sorting

          B,1

          A,2

          Z,3    

          Y,4

          ];

Then in sort window click on the expression and type the field name as Sorting.

If you have less values then you can use this

=match(Name,'B','A','Z','Y')

in Sort -> Expression.

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Thanks, exactly what I was looking

Not applicable
Author

Hi,

I tried all of this but isn't working

if([Pi Py Jan Affluence new]='<100k',1,if([Pi Py Jan Affluence new]='100k-250k',2,if([Pi Py Jan Affluence new]='250k-1M',3,if([Pi Py Jan Affluence new]='1-3M',4,if([Pi Py Jan Affluence new]='3M+',5,if([Pi Py Jan Affluence new]='Established Not New',6,7))))))

I don't understand where I am going wrong. The sorting isn't working and I am using a people chart