Home / Sheets questions cookbook / Top customers by revenue
Google Sheets · Question cookbook

How to Find Your Top Customers by Revenue in Google Sheets

Total every customer's sales, sort biggest first, keep the top ten. One QUERY formula does it, and the sample data below shows exactly what comes back.

By · Published November 8, 2026

The short answer: =QUERY(Orders!A:K, "select C, sum(J) where year(A) = 2026 group by C order by sum(J) desc limit 10 label sum(J) 'Revenue'", 1). It groups the order lines by customer, adds up revenue, and returns the ten biggest. In the sample data, Corner Coffee House leads with $54,529 in 2026.

The sample data

ABCDEFGHIJK
1DateOrder IDCustomerRegionChannelProductCategoryQtyUnit priceRevenueCost
22025-01-01SO-10001Tin Roof CaféNortheastSales repSip Lids (case of 1,000)Supplies654324198
32025-01-01SO-10001Tin Roof CaféNortheastSales repEspresso Roast 5 lbCoffee1068680370
42025-01-01SO-10002Foxglove CaféNortheastOnline storeSip Lids (case of 1,000)Supplies1545433
52025-01-01SO-10002Foxglove CaféNortheastOnline storeCold Brew Concentrate 1 galCoffee842336152
62025-01-01SO-10003Ember CaféMidwestOnline storeSip Lids (case of 1,000)Supplies454216132
…8,115 more rows
Orders

Sample data: a tab named Orders with 8,120 order lines from January 2025 to October 2026, one row per order line. Revenue is Qty × Unit price; Cost is the line's cost of goods (Qty × unit cost). Download orders.csv and import it (File → Import) to follow along. The business is fictional.

The classic way: QUERY with GROUP BY

Add a tab for the answer and type this in A1. It reads the whole Orders tab (header in row 1), keeps 2026 rows, totals column J (Revenue) per customer in column C, and sorts the totals biggest first:

=QUERY(Orders!A:K, "select C, sum(J) where year(A) = 2026 group by C order by sum(J) desc limit 10 label sum(J) 'Revenue'", 1)

What each part does: group by C makes one row per customer, sum(J) adds their revenue, order by sum(J) desc puts the biggest first, limit 10 keeps ten, and label sum(J) 'Revenue' replaces the default heading "sum Revenue". Drop where year(A) = 2026 for all time, or use where A >= date '2026-07-01' for a custom start date (QUERY dates must be written date 'yyyy-mm-dd').

Example on sample data
fx=QUERY(Orders!A:K, "select C, sum(J) where year(A) = 2026 group by C order by sum(J) desc limit 10 label sum(J) 'Revenue'", 1)
AB
1CustomerRevenue
2Corner Coffee House$54,529
3Ivy Lane Office Pantry$54,160
4West End Café$52,733
5Tin Roof Kitchen$52,656
6Mill Pond Market$51,414
7Blue Door Bistro$50,092
8Juniper Kitchen$47,387
9Highline Café$46,732
10Willow Coffee House$46,366
11Ember Café$45,641
SummaryOrders

Computed from the sample CSV above. Cells formatted as currency and percent.

Prefer a pivot table? Select the Orders data, then Insert → Pivot table. Add Customer under Rows and Revenue under Values (SUM). In the Rows settings, sort by SUM of Revenue, descending. Add Date as a filter to limit it to 2026. Same numbers, but you set the top-10 cut yourself.

Gotchas

The one-cell way: =QUIRIZ

With the Quiriz add-on for Google Sheets, you type the question instead of building the formula. =QUIRIZ does not read the cells around it: it answers from the datasets in your Quiriz account. For this example, upload orders.csv as a dataset, or connect your Shopify store. You can also add a Google Sheet itself as a dataset that refreshes on a schedule. Then, in any empty cell:

=QUIRIZ("top 10 customers by revenue in 2026", "table")

The "table" mode spills the answer down and to the right from that cell, header row first:

Example on sample data
fx=QUIRIZ("top 10 customers by revenue in 2026", "table")
AB
1CustomerRevenue
2Corner Coffee House$54,529
3Ivy Lane Office Pantry$54,160
4West End Café$52,733
5Tin Roof Kitchen$52,656
6Mill Pond Market$51,414
7Blue Door Bistro$50,092
8Juniper Kitchen$47,387
9Highline Café$46,732
10Willow Coffee House$46,366
11Ember Café$45,641
Sheet1

Same figures as the formula result above, from the same sample data. The spilled cells are plain numbers, so you can format them, total them or chart them; here they are formatted as currency and percent. Column headings are written with each answer and may be worded differently.

The other modes: "verbose" (the default) answers in a sentence, "bullets" writes two to four points one per cell, and "notes" adds how the figure was calculated. Install Quiriz for Google Sheets and try the question on your own data.

Ask the question, get the table

Quiriz answers business questions in a Google Sheets cell, from your imported files, scheduled Google Sheets and connected tools. Free to start.

Install for Google Sheets →

Free on the Google Workspace Marketplace. Or try it on sample data first, no signup.

Frequently asked questions

How do I rank customers by sales in Google Sheets?
Use QUERY: =QUERY(Orders!A:K, "select C, sum(J) group by C order by sum(J) desc", 1), where C is the customer column and J is revenue. Add limit 10 for the top ten. A pivot table with Customer in Rows, SUM of Revenue in Values, sorted descending, gives the same ranking.
Why does the same customer appear twice in my ranking?
The names are not identical: a trailing space, different capitalization or an accented letter makes QUERY treat them as two customers. Clean the names with TRIM, or group on a customer ID instead of the name.
Can I get the top customers for a specific date range?
Yes. Add a where clause with QUERY date literals: where A >= date '2026-07-01' and A < date '2026-10-01' keeps the third quarter. The date literal must be written yyyy-mm-dd.