18.1Ranking with RANKX
In Excel
| Excel | RANK.EQ |
|---|---|
| Match |
Who is your top customer? RANKX ranks the values of a table by a measure. A single argument makes all the difference, the list of items to rank.
18.1.1The syntax of RANKX
RANKX calculates an expression, often a measure, for each row of a table, then returns the rank of the current row.
It first expects the table of the items to rank, then the expression calculated for each of them, often a measure. The last three arguments are optional. The default order is DESC, and the largest figure gets rank 1. In this lesson, we write it out so that you can see it. With ASC, the smallest figure comes first. The third argument, the value, stays empty in this lesson.
“I want the rank of each customer, ordering all the customers from the highest revenue to the lowest, and reading the place of each one.”
| Name | Rank |
|---|---|
| Orvane | 1 |
| Kumora | 2 |
| Ribelia | 3 |
| Movara | 3 |
| Northel | 5 |
| Talvio | 6 |
| Sam Lee | 7 |
| Total | 1 |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
Ribelia and Movara both reach 250,000. They share rank 3, and rank 4 is skipped.
The “Total” row shows 1. On this row, RANKX calculates the revenue of the row, 1,700,000, then compares it with that of the seven customers that ALL provides. It beats them all, hence rank 1. You will often hide this rank with ISINSCOPE, covered with the essential functions.
Practice
Each exercise is solved with the function you just discovered. Two exercises per function, a direct use and a combined use, from easiest to hardest, on data other than the course data. Pick the right formula out of five.
Direct useMeasureDifficulty
A cycling championship already has a “Points” measure, the sum of the “Points” column of the “Results” table. In a table by rider, write the “Ranking” measure, which orders all the riders from the most points to the fewest.
Results Rider Points Lina 45 Marc 60 Noé 52 Which formula should you write for “Ranking”?
Combined useMeasureDifficulty
A swimming competition already has a “Time” measure, which returns a swimmer’s time, in seconds. The best swimmer has the shortest time. In a table by swimmer, with the Races[Swimmer] column, write the “Place” measure, which gives first place to the shortest time.
Races Swimmer Time Ana 62 Ben 58 Cléo 65
The rest of this lesson is part of izyDAX Pro
You have just read the first section. The next 2, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.