Case 3: top customers
A few customers bring most of the sales. You give every customer a rank and pull the five biggest as a list for management.
In short: RANKX(ALL(Customer[Customer]), [Total Sales]) gives every customer its rank. A fixed list of the five biggest comes from the DAX query EVALUATE TOPN(5, SUMMARIZECOLUMNS(…), [Sales]) ORDER BY [Sales] DESC.
Task 1: customer rank
Task Which customers matter most in 2026? Create the measure "Customer Rank": the rank of every customer by [Total Sales], with the biggest customer ranked 1.
Orders 221 rows, 5 columns
| OrderID | Date | CustomerID | RepID | Amount |
|---|---|---|---|---|
| 1001 | 4 Jan 2025 | 105 | 3 | 2850 |
| 1002 | 16 Jan 2025 | 101 | 1 | 8730 |
| 1003 | 19 Jan 2025 | 105 | 4 | 4650 |
| 1004 | 1 Feb 2025 | 103 | 2 | 5210 |
| 1005 | 11 Feb 2025 | 109 | 5 | 11440 |
| 1006 | 11 Feb 2025 | 111 | 6 | 2000 |
| 1007 | 11 Feb 2025 | 113 | 2 | 3850 |
| 1008 | 12 Feb 2025 | 103 | 2 | 5670 |
| 1009 | 13 Feb 2025 | 104 | 2 | 7380 |
| 1010 | 13 Feb 2025 | 109 | 5 | 8250 |
| 1011 | 16 Feb 2025 | 101 | 1 | 7650 |
| 1012 | 21 Feb 2025 | 101 | 2 | 6750 |
Showing the first 12 of 221 rows.
Measures: [Total Sales]
Customer 16 rows, 3 columns
| CustomerID | Customer | Industry |
|---|---|---|
| 101 | Berg Engineering Ltd | Manufacturing |
| 102 | Northlight Trading Co | Retail |
| 103 | Harbor Logistics Inc | Services |
| 104 | Crane Electric plc | Manufacturing |
| 105 | Sunfield Markets LLC | Retail |
| 106 | Alpine Tools Ltd | Manufacturing |
| 107 | Riverside Consulting LLC | Services |
| 108 | Lakeside Print Co | Services |
| 109 | Rhine Steel Inc | Manufacturing |
| 110 | West End Fashion Ltd | Retail |
| 111 | Valley Wine Merchants LLC | Retail |
| 112 | Midland Services Ltd | Services |
Showing the first 12 of 16 rows.
SalesRep 6 rows, 3 columns
| RepID | Name | Region |
|---|---|---|
| 1 | Emma Clarke | North |
| 2 | Tom Wolf | North |
| 3 | Ravi Patel | South |
| 4 | Lucy Evans | South |
| 5 | Sam Kerr | West |
| 6 | Mia Lang | West |
Target 144 rows, 3 columns
| Date | RepID | TargetAmount |
|---|---|---|
| 1 Jan 2025 | 1 | 7500 |
| 1 Feb 2025 | 1 | 7500 |
| 1 Mar 2025 | 1 | 7500 |
| 1 Apr 2025 | 1 | 7500 |
| 1 May 2025 | 1 | 9000 |
| 1 Jun 2025 | 1 | 9500 |
| 1 Jul 2025 | 1 | 9500 |
| 1 Aug 2025 | 1 | 7500 |
| 1 Sep 2025 | 1 | 7500 |
| 1 Oct 2025 | 1 | 9000 |
| 1 Nov 2025 | 1 | 9500 |
| 1 Dec 2025 | 1 | 9000 |
Showing the first 12 of 144 rows.
Measures: [Total Target]
Date 730 rows, 4 columns
| Date | Year | Month | MonthName |
|---|---|---|---|
| 1 Jan 2025 | 2025 | 1 | Jan |
| 2 Jan 2025 | 2025 | 1 | Jan |
| 3 Jan 2025 | 2025 | 1 | Jan |
| 4 Jan 2025 | 2025 | 1 | Jan |
| 5 Jan 2025 | 2025 | 1 | Jan |
| 6 Jan 2025 | 2025 | 1 | Jan |
| 7 Jan 2025 | 2025 | 1 | Jan |
| 8 Jan 2025 | 2025 | 1 | Jan |
| 9 Jan 2025 | 2025 | 1 | Jan |
| 10 Jan 2025 | 2025 | 1 | Jan |
| 11 Jan 2025 | 2025 | 1 | Jan |
| 12 Jan 2025 | 2025 | 1 | Jan |
Showing the first 12 of 730 rows.
The lesson on RANKX and TOPN explains how RANKX compares and why ALL belongs there. The rank follows the 2026 filter; if you pick 2025 in the slicer, it changes.
Task 2: the five biggest customers as a list
Task For a list for management: write a DAX query with the five biggest customers across both years, each row with the customer and the column "Sales" from [Total Sales], the largest at the top.
Orders 221 rows, 5 columns
| OrderID | Date | CustomerID | RepID | Amount |
|---|---|---|---|---|
| 1001 | 4 Jan 2025 | 105 | 3 | 2850 |
| 1002 | 16 Jan 2025 | 101 | 1 | 8730 |
| 1003 | 19 Jan 2025 | 105 | 4 | 4650 |
| 1004 | 1 Feb 2025 | 103 | 2 | 5210 |
| 1005 | 11 Feb 2025 | 109 | 5 | 11440 |
| 1006 | 11 Feb 2025 | 111 | 6 | 2000 |
| 1007 | 11 Feb 2025 | 113 | 2 | 3850 |
| 1008 | 12 Feb 2025 | 103 | 2 | 5670 |
| 1009 | 13 Feb 2025 | 104 | 2 | 7380 |
| 1010 | 13 Feb 2025 | 109 | 5 | 8250 |
| 1011 | 16 Feb 2025 | 101 | 1 | 7650 |
| 1012 | 21 Feb 2025 | 101 | 2 | 6750 |
Showing the first 12 of 221 rows.
Measures: [Total Sales]
Customer 16 rows, 3 columns
| CustomerID | Customer | Industry |
|---|---|---|
| 101 | Berg Engineering Ltd | Manufacturing |
| 102 | Northlight Trading Co | Retail |
| 103 | Harbor Logistics Inc | Services |
| 104 | Crane Electric plc | Manufacturing |
| 105 | Sunfield Markets LLC | Retail |
| 106 | Alpine Tools Ltd | Manufacturing |
| 107 | Riverside Consulting LLC | Services |
| 108 | Lakeside Print Co | Services |
| 109 | Rhine Steel Inc | Manufacturing |
| 110 | West End Fashion Ltd | Retail |
| 111 | Valley Wine Merchants LLC | Retail |
| 112 | Midland Services Ltd | Services |
Showing the first 12 of 16 rows.
SalesRep 6 rows, 3 columns
| RepID | Name | Region |
|---|---|---|
| 1 | Emma Clarke | North |
| 2 | Tom Wolf | North |
| 3 | Ravi Patel | South |
| 4 | Lucy Evans | South |
| 5 | Sam Kerr | West |
| 6 | Mia Lang | West |
Target 144 rows, 3 columns
| Date | RepID | TargetAmount |
|---|---|---|
| 1 Jan 2025 | 1 | 7500 |
| 1 Feb 2025 | 1 | 7500 |
| 1 Mar 2025 | 1 | 7500 |
| 1 Apr 2025 | 1 | 7500 |
| 1 May 2025 | 1 | 9000 |
| 1 Jun 2025 | 1 | 9500 |
| 1 Jul 2025 | 1 | 9500 |
| 1 Aug 2025 | 1 | 7500 |
| 1 Sep 2025 | 1 | 7500 |
| 1 Oct 2025 | 1 | 9000 |
| 1 Nov 2025 | 1 | 9500 |
| 1 Dec 2025 | 1 | 9000 |
Showing the first 12 of 144 rows.
Measures: [Total Target]
Date 730 rows, 4 columns
| Date | Year | Month | MonthName |
|---|---|---|---|
| 1 Jan 2025 | 2025 | 1 | Jan |
| 2 Jan 2025 | 2025 | 1 | Jan |
| 3 Jan 2025 | 2025 | 1 | Jan |
| 4 Jan 2025 | 2025 | 1 | Jan |
| 5 Jan 2025 | 2025 | 1 | Jan |
| 6 Jan 2025 | 2025 | 1 | Jan |
| 7 Jan 2025 | 2025 | 1 | Jan |
| 8 Jan 2025 | 2025 | 1 | Jan |
| 9 Jan 2025 | 2025 | 1 | Jan |
| 10 Jan 2025 | 2025 | 1 | Jan |
| 11 Jan 2025 | 2025 | 1 | Jan |
| 12 Jan 2025 | 2025 | 1 | Jan |
Showing the first 12 of 730 rows.
This exercise is part of Premium.
Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.
See Premium Already Premium? Log in
The first exercise in this lesson is free.
DAX queries start with EVALUATE and return a table, as in the lesson on DAX queries. Without a year filter both years count.
Common mistakes
ORDER BY forgotten
TOPN selects five rows but does not sort them. Without ORDER BY the list can come in any order, and the exercise reports that the sorting is missing.
Wrong column name
The new column is called "Sales" in the query. In TOPN and ORDER BY you write it as [Sales], not [Total Sales].
In real Power BI
- A visual with the top 5 needs no query: the filter pane offers the filter type "Top N" for the Customer field.
- You write the query in the DAX query view of Power BI Desktop and can copy the result from there.
Check your result
- Task 1: In 2026 Berg Engineering Ltd ranks 1 with 122,850, Rhine Steel Inc ranks 2, Alpine Tools Ltd ranks 3.
- Task 2: Across both years the list contains Berg Engineering Ltd (199,620), Rhine Steel Inc, Alpine Tools Ltd, Crane Electric plc and Sunfield Markets LLC (94,580).
Back to case 2 or the course overview.