Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Adding a "rank" column to a pivot (or straight) table

Is it possible to add a column generically called "Rank" to show the position of a line in a pivot or straight table?

Practically I want to create a top with the cities sorted descending by their population:

Rank City sum(Population)

1 New York 20 000 000

2 Los Angeles 15 000 000

3 Washington 7 000 000

.............................................................

100 Atlanta 150 000

2 Replies
Not applicable
Author

In the case of the straight table, I used the function "rowno()" , I brought it as the first column and I got what I need. Until now, I have tried to create a synthetic column, but it seems that is easier to create an expression and after that to bring it on the position you need in the table.

Are there other possibilities to do this?

Not applicable
Author

The rowno will work if the table is sorted as you want, you can use rank(Sum(Population)) as expression I think.