Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ankit777
Specialist
Specialist

Pivot Sorting

Hi All

I have three dimension in my pivot, Country, city and Week.

I have to show top 4 city and remaining as Others, in each country by bookings(sorting based on total bookings) and there weekly sales. 

I used below calculated field for city(second dimension.

=aggr(if(rank(sum(Bookings))<=5,city,'Others'),country,city)

This gets me correct results, but I want to sort it by first city in descending bookings then Others.

How can we achieve this?

Labels (2)
1 Reply
agni_gold
Specialist III
Specialist III

= aggr(if(num(rank(sum(Bookings),4))<=5,city,'Others'),country,city)

or 

=  if(aggr(num(rank(sum(Bookings),4)),country,city)<=5,city,'Others')