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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Fareeha123
Contributor III
Contributor III

Sort the Names by Rank

Hi, 

I have a pivot table in which I am showing top 10 Clients and remaining in "Others". Clients that are bucket in "Others" category are shown in Text and Image box below the pivot table as seen in below image. Currently they are showing in alphabetical order. User wants them to be sorted based upon rank. 

How can i achieve that? 

 

Below is the formula used

 

=if(GetSelectedCount([Currency])=0 or Currency='EUR',
concat(
distinct if(
aggr(
rank(
Sum({<CSDR_Detection_Date_MonthEnd={'$(=$(vEndDate_1))'}>}Positive_EURAmount),1,1
),
CSDR_Counterparty_Name
) >= 11 and Positive_EURAmount<>0,

CSDR_Counterparty_Name
),
', '
),

concat(
distinct if(
aggr(
rank(
Sum({<CSDR_Detection_Date_MonthEnd={'$(=$(vEndDate_1))'}>}Positive_USDAmount),1,1
),
CSDR_Counterparty_Name
) >= 11 and Positive_USDAmount<>0,

CSDR_Counterparty_Name
),
', '
)
)

 

 

Fareeha123_0-1764866386118.png

 

 

 

 

Labels (3)
1 Solution

Accepted Solutions
ysalvi43
Contributor III
Contributor III

Hello Please find formula for reference which worked on the testing data 
Formula: 

Concat(
Aggr(
If(Rank(Sum(Sales)) > 10, Client),
Client
),
', ',
Aggr(Rank(Sum(Sales)), Client)
)

ysalvi43_0-1764924004725.png

Thanks 

 

 

View solution in original post

2 Replies
ysalvi43
Contributor III
Contributor III

Hello Please find formula for reference which worked on the testing data 
Formula: 

Concat(
Aggr(
If(Rank(Sum(Sales)) > 10, Client),
Client
),
', ',
Aggr(Rank(Sum(Sales)), Client)
)

ysalvi43_0-1764924004725.png

Thanks 

 

 

Fareeha123
Contributor III
Contributor III
Author

Thanks Ysalvi, 

Aggr and rank again at the end helped in sorting them by rank. This is final formula that worked 

 

 

=if(GetSelectedCount([Currency])=0 or Currency='EUR',
concat(
if(
aggr(rank(Sum({<CSDR_Detection_Date_MonthEnd={'$(=$(vEndDate_1))'}>}Positive_EURAmount),1,1),CSDR_Counterparty_Name)>=11
and aggr(Sum({<CSDR_Detection_Date_MonthEnd={'$(=$(vEndDate_1))'}>}Positive_EURAmount),CSDR_Counterparty_Name)<>0,
CSDR_Counterparty_Name),
',',
aggr(rank(Sum({<CSDR_Detection_Date_MonthEnd={'$(=$(vEndDate_1))'}>}Positive_EURAmount),1,1),CSDR_Counterparty_Name)
),
concat(
if(
aggr(rank(Sum({<CSDR_Detection_Date_MonthEnd={'$(=$(vEndDate_1))'}>}Positive_USDAmount),1,1),CSDR_Counterparty_Name)>=11
and aggr(Sum({<CSDR_Detection_Date_MonthEnd={'$(=$(vEndDate_1))'}>}Positive_USDAmount),CSDR_Counterparty_Name)<>0,
CSDR_Counterparty_Name),
',',
aggr(rank(Sum({<CSDR_Detection_Date_MonthEnd={'$(=$(vEndDate_1))'}>}Negative_USDAmount),1,1),CSDR_Counterparty_Name)
)
)