Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sorting specific value to top

Hi all,

I have a straight table in which I'm trying to sort by a couple of dimensions but I'm having trouble with the usual methods.

Fields are as follows:

ProductID

Product Default DepartmentID

Department ID

TotalSales

So to explain the above, each product has a default DepartmentID, but can have activity from other departments in the 'TotalSales' field. The straight table looks a bit like this:

   

ProductID

Product

DefaultDeptID

DepartmentIDTotalSales
AA1ABC5ABC112
AA1ABC5ABC255
AA1ABC5ABC418
AA1ABC5ABC519
BB2ABC3ABC455
BB2ABC3ABC774
BB2ABC3ABC314
CC3ABC2ABC230
CC3ABC2ABC597
CC3ABC2ABC318

The sort order I need in this table should be:

ProductID (Text; Ascending)

Then I need to sort the DepartmentID value, putting the DepartmentID which matches the ProductDefaultDeptID to the top of the group(bold in the above table) and then the sort order of the remaining DepartmentID/Value is not important.

So of course, ProductID is promoted to the top of the list in the Sort tab and sorted by text(ascending); DepartmentID is second in the list. I've tried expressions such as

if([DepartmentID]=[ProductDefaultDeptID],1,2)

if([DepartmentID]=[ProductDefaultDeptID],1,0)

=[DepartmentID]=[ProductDefaultDeptID]

=WildMatch([DepartmentID],[ProductDefaultDeptID],'?')

=WildMatch([DepartmentID],[ProductDefaultDeptID],'*')

=MixMatch([DepartmentID],[ProductDefaultDeptID],'*')

The above expressions I have tested out as a calculated dimension in the same table to check they are evaluating as expected which it always is.

It seems like a fairly simple requirement; and the attempted solutions so far seem very straightforward and very similar to things I've done in the past for custom sort orders. If anyone has any insight into this problem I'd appreciate their input - I'm hoping this has a solution and is not a bug with QV.

I'm using v11.20 SR13

Thanks

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Add another expression match([Product Default DepartmentID],Department ID). Sort on that expression Numeric Value - descending. Then hide the expression on the Presentation tab.


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar

Add another expression match([Product Default DepartmentID],Department ID). Sort on that expression Numeric Value - descending. Then hide the expression on the Presentation tab.


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks Gysbert, that has worked perfectly!

That's a great solution!