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
OrderIDDateCustomerIDRepIDAmount
10014 Jan 202510532850
100216 Jan 202510118730
100319 Jan 202510544650
10041 Feb 202510325210
100511 Feb 2025109511440
100611 Feb 202511162000
100711 Feb 202511323850
100812 Feb 202510325670
100913 Feb 202510427380
101013 Feb 202510958250
101116 Feb 202510117650
101221 Feb 202510126750

Showing the first 12 of 221 rows.

Measures: [Total Sales]

Customer 16 rows, 3 columns
CustomerIDCustomerIndustry
101Berg Engineering LtdManufacturing
102Northlight Trading CoRetail
103Harbor Logistics IncServices
104Crane Electric plcManufacturing
105Sunfield Markets LLCRetail
106Alpine Tools LtdManufacturing
107Riverside Consulting LLCServices
108Lakeside Print CoServices
109Rhine Steel IncManufacturing
110West End Fashion LtdRetail
111Valley Wine Merchants LLCRetail
112Midland Services LtdServices

Showing the first 12 of 16 rows.

SalesRep 6 rows, 3 columns
RepIDNameRegion
1Emma ClarkeNorth
2Tom WolfNorth
3Ravi PatelSouth
4Lucy EvansSouth
5Sam KerrWest
6Mia LangWest
Target 144 rows, 3 columns
DateRepIDTargetAmount
1 Jan 202517500
1 Feb 202517500
1 Mar 202517500
1 Apr 202517500
1 May 202519000
1 Jun 202519500
1 Jul 202519500
1 Aug 202517500
1 Sep 202517500
1 Oct 202519000
1 Nov 202519500
1 Dec 202519000

Showing the first 12 of 144 rows.

Measures: [Total Target]

Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

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
OrderIDDateCustomerIDRepIDAmount
10014 Jan 202510532850
100216 Jan 202510118730
100319 Jan 202510544650
10041 Feb 202510325210
100511 Feb 2025109511440
100611 Feb 202511162000
100711 Feb 202511323850
100812 Feb 202510325670
100913 Feb 202510427380
101013 Feb 202510958250
101116 Feb 202510117650
101221 Feb 202510126750

Showing the first 12 of 221 rows.

Measures: [Total Sales]

Customer 16 rows, 3 columns
CustomerIDCustomerIndustry
101Berg Engineering LtdManufacturing
102Northlight Trading CoRetail
103Harbor Logistics IncServices
104Crane Electric plcManufacturing
105Sunfield Markets LLCRetail
106Alpine Tools LtdManufacturing
107Riverside Consulting LLCServices
108Lakeside Print CoServices
109Rhine Steel IncManufacturing
110West End Fashion LtdRetail
111Valley Wine Merchants LLCRetail
112Midland Services LtdServices

Showing the first 12 of 16 rows.

SalesRep 6 rows, 3 columns
RepIDNameRegion
1Emma ClarkeNorth
2Tom WolfNorth
3Ravi PatelSouth
4Lucy EvansSouth
5Sam KerrWest
6Mia LangWest
Target 144 rows, 3 columns
DateRepIDTargetAmount
1 Jan 202517500
1 Feb 202517500
1 Mar 202517500
1 Apr 202517500
1 May 202519000
1 Jun 202519500
1 Jul 202519500
1 Aug 202517500
1 Sep 202517500
1 Oct 202519000
1 Nov 202519500
1 Dec 202519000

Showing the first 12 of 144 rows.

Measures: [Total Target]

Date 730 rows, 4 columns
DateYearMonthMonthName
1 Jan 202520251Jan
2 Jan 202520251Jan
3 Jan 202520251Jan
4 Jan 202520251Jan
5 Jan 202520251Jan
6 Jan 202520251Jan
7 Jan 202520251Jan
8 Jan 202520251Jan
9 Jan 202520251Jan
10 Jan 202520251Jan
11 Jan 202520251Jan
12 Jan 202520251Jan

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).

Next: case 4, sales growth

Sales year-to-date and the growth of every region over the prior year.

Go to case 4

Back to case 2 or the course overview.

Write to us

Choose language

Select your preferred language