Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Custom Sort

I am pretty newish to Qlikview and I am trying to custom sort a listbox I created. 

Currently the data in the listbox looks like this:

    

     0000-0600

     0600-1200

     0600-1800 (Officer)

     0900-1500

     1200-1800

     1800-0600 (Officer)

     1800-2400

What I want is this:

     0000-0600

     0600-1200

     0900-1500

     1200-1800

     1800-2400

     0600-1800 (Officer)

     1800-0600 (Officer)

Any ideas?

Thanks

~Norman Rea

19 Replies
Gysbert_Wassenaar

Sort by expression:

=match(only({1} MyField), '0000-0600','0600-1200','0900-1500','1200-1800','1800-2400','0600-1800 (Officer)','1800-0600 (Officer)')

Or first load the field values in the order you want them in a table in the script before loading the main data. If you do that you can sort by Load Order to get the sorting you want.


talk is cheap, supply exceeds demand
its_anandrjs

Hi,

Try numeric sort option of the chart in the chart properties or load order.

Regards

Anand

swarup_malli
Specialist
Specialist

Norm Rea,

Try coding this in the first sheet of the script editor let it be the first table

[some table name]:

LOAD * INLINE [

    NameOfTheListBoxYouWantyToCustomSort
       0000-0600

       0600-1200

       0900-1500

       1200-1800

       1800-2400

        0600-1800 (Officer)

       1800-0600 (Officer)

]

;



DROP TABLE  [some table name];

should work !

Not applicable
Author

The values are loaded out of order so no load order and with the numeric sort nothing happens.  This date comes form an excel table with columns: Member Name, Shift and Crew.  The shift is were these values reside.

~Norm

its_anandrjs

Hi,

Or another option

LOAD * Inline

[    Recs

     0000-0600

     0600-1200

     0600-1800 (Officer)

     0900-1500

     1200-1800

     1800-0600 (Officer)

     1800-2400 ];

Go to properties >> Sort >> write expression Len(Recs)

Sortorder.png

Note:- Assume this is the example and in place of Recs use your fieldname.

Regards

Anand

Not applicable
Author

Problem data can change so it is loaded from and excel sheet.

Not applicable
Author

Close but my 0900-1500 is not in the right place.

its_anandrjs

Hi,

If this is identified and confirmed the length of records which is numeric is 9 then try the below script

A:

LOAD * Inline

[     Recs

     0000-0600

     0600-1200

     0600-1800 (Officer)

     0900-1500

     1200-1800

     1800-0600 (Officer)

     1800-2400 ];

New:

LOAD Recs, RowNo() as Rid Resident A Where Len(Recs) = 9;

Concatenate

LOAD Recs, RowNo() as Rid Resident A Where Len(Recs) > 9;

DROP Table A;

And sort it by Rowid

Sortbyrow.png

Regards

Anand

morganaaron
Specialist
Specialist

Did you also leave Numeric Value (Ascending) ticked? I've got both selected and it seems to work okay..