Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Mohan23912391
Contributor
Contributor

Pivot Table in QS - Sorting

Hi Team,

My first dimension is “Customer Name”, my second dimension is “Month” and my values/expression are sales values. I want my table to sort the customers descending by their respective sales values (Qlik Sense does that already), but if I expand the customer dimension to see the sales per customer per month, I would like that sorted from January to December.

This does not work. Instead, Qlik Sense sorts the months also by sales figures (per customer per month) in a descending order.

Example:

Customer Sum(Sales)
Customer B 1,000
   Feb    700
   Mar    200
  Jan    100
Customer D    800
  Jan     400
   Mar     300
  Feb     100

 

But I want it to be:

Customer Sum(Sales)
Customer B 1,000
   Jan    100
   Feb    700
  Mar    200
Customer D    800
  Jan     400
   Feb     100
  Mar

    300

Labels (1)
  • Chart

1 Solution

Accepted Solutions
Kushal_Chawda

@Mohan23912391  use  sort by measure option for Month field and put below expression

Kushal_Chawda_0-1684442822249.png

 

=match(Only({1}Month),'Jan','Feb','Mar','Apr','May','Jun','July'....)

View solution in original post

3 Replies
Kushal_Chawda

@Mohan23912391  use  sort by measure option for Month field and put below expression

Kushal_Chawda_0-1684442822249.png

 

=match(Only({1}Month),'Jan','Feb','Mar','Apr','May','Jun','July'....)
Mohan23912391
Contributor
Contributor
Author

In continuation to above, I have another scenario

Customer Sum(Sales)
Customer B 1,000
   Feb    700
   Mar    200
  Jan    100
Customer D    800
  Jan     400
   Mar     300
  Feb     100

 

I want output like below

Customer Sum(Sales)
Customer D    800
  Jan     400
   Mar     300
  Feb

    100

Customer B

1,000

Feb

700

Mar

200

Jan

100

 

- customer values should be in a fixed order that I define (there are 20 customers and I define the order)

- 2nd dimension(Month) should be sorted as per Sum(sales) in descending order

How to get this.

I have set customer_sort_field in 1st dimension's sorting, then have put sum(sales) in 2nd dimension's sorting order.

But it's not working

Kushal_Chawda

@Mohan23912391  In this case you won't be able to sort it by expression for Month . You need to create calculated dimension for Month using dual then sort Month Numerically descending

=dual(Month, aggr(sum(aggr(NODISTINCT rank(Customer,4,1),Month)*1e5)+sum(Sales), Customer,Month))