Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Support Cases coming to Qlik Community Oct. 4! Start chats, open cases, explore resources: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
VivenReddy
Partner
Partner

Listbox sorting by expression not working

I've been struggling with listbox sorting for a couple of days. I hope someone can assist. My listbox has a field and 2 expressions. I am not able to get it to sort by Description (1st expression). I am able to sort by Sales (2nd expression). I have also tried doing the sort in the load script but that has not helped either. See screenshot of all 3 tests. Attached is my qvw. I am using QV 12.4 SR3.

VivenReddy_0-1613592745933.png

 

1 Solution

Accepted Solutions
rubenmarin

Hi @VivenReddy, sort by expression expects a number to sort, you can try with:

Ord(Left(Lower(Description),1))*1e6+Ord(Mid(Lower(Description),2,1))*1e3+Ord(Mid(Lower(Description),3,1))

At least to sort by the fist 3 letters.

Another option can be:

Num((Ord(Left(Lower(Description),1))-96),'00')
 &Num((Ord(Mid(Lower(Description),2,1))-96),'00')
 &Num((Ord(Mid(Lower(Description),3,1))-96),'00')
 ...

But it will be better if you can add another field to each description that sets the order of the Descriptions, something Like:

Left Join(DataTable)
LOAD Distinct Description,
	RecNo() as DescriptionOrder
Resident DataTable
Order By Description;

So you can use Min({1} DescriptionOrder) to sort values

View solution in original post

2 Replies
rubenmarin

Hi @VivenReddy, sort by expression expects a number to sort, you can try with:

Ord(Left(Lower(Description),1))*1e6+Ord(Mid(Lower(Description),2,1))*1e3+Ord(Mid(Lower(Description),3,1))

At least to sort by the fist 3 letters.

Another option can be:

Num((Ord(Left(Lower(Description),1))-96),'00')
 &Num((Ord(Mid(Lower(Description),2,1))-96),'00')
 &Num((Ord(Mid(Lower(Description),3,1))-96),'00')
 ...

But it will be better if you can add another field to each description that sets the order of the Descriptions, something Like:

Left Join(DataTable)
LOAD Distinct Description,
	RecNo() as DescriptionOrder
Resident DataTable
Order By Description;

So you can use Min({1} DescriptionOrder) to sort values

View solution in original post

VivenReddy
Partner
Partner
Author

Thank you for your response Ruben.