Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
gfisch13
Creator II
Creator II

Pivot Table - Sorting

Hi, I'm hoping there is an easy way to implement sorting on this pivot table.  Basically, I'd like each expense type column to be sorted at the users will.  So using Lodging as an example I'd like the user to click something and the data would be sorted by descending transaction amount for the Lodging field.   Any help is appreciated.  I've seen some rather complicated entries on this topic on this board, and since I'm a novice was hoping there is an easier way??  Thanks!

1 Solution

Accepted Solutions
sunny_talwar

Can you check if attached is what you want

Script:

Table:

CrossTable(Type, Data, 2)

LOAD AcctNum,

     Name,

     [Car Rental],

     Lodging,

     Airline

FROM

[PivotExample.xlsx]

(ooxml, embedded labels, table is Sheet1);

Sort:

LOAD * Inline [

Sort

Car Rental

Lodging

Airline

];

Here Sort field can be used to decide which field you want to sort by.

By Lodging

Capture.PNG

By Airline

Capture.PNG

By Car Rental

Capture.PNG

Used a sort expression

Sum({<Type =p(Sort)>} Data)

Capture.PNG

View solution in original post

12 Replies
sunny_talwar

Is it possible to share a sample with what the expectation is?

gfisch13
Creator II
Creator II
Author

Here is a simple snapshot that I've done in Excel.  Notice that the Lodging column is sorted in descending order.  I'd like to have the user be able to select which column they would like sorted.  Hope this helped.  I cannot share the live data.Pivot2.JPG

sunny_talwar

Can you share the above data in the Excel format atleast

gfisch13
Creator II
Creator II
Author

Sure - here you go.........

sunny_talwar

Can you check if attached is what you want

Script:

Table:

CrossTable(Type, Data, 2)

LOAD AcctNum,

     Name,

     [Car Rental],

     Lodging,

     Airline

FROM

[PivotExample.xlsx]

(ooxml, embedded labels, table is Sheet1);

Sort:

LOAD * Inline [

Sort

Car Rental

Lodging

Airline

];

Here Sort field can be used to decide which field you want to sort by.

By Lodging

Capture.PNG

By Airline

Capture.PNG

By Car Rental

Capture.PNG

Used a sort expression

Sum({<Type =p(Sort)>} Data)

Capture.PNG

gfisch13
Creator II
Creator II
Author

Perfect...........I feel like I'll never learn the proper syntax for these expressions.  Thanks for all your help!!!!

sunny_talwar

No problem at all, I am glad to help

Anonymous
Not applicable

George , maybe this help you...

Set Analysis Wizard for QlikView | qlikblog.at

Andrea.

gfisch13
Creator II
Creator II
Author

Andrea - wow - that will simplify things!!  Thank you!!!