Home / Sheets questions cookbook / Sales by product category
Google Sheets · Question cookbook

How to Show Sales by Product Category in Google Sheets

Which categories bring in the money, and what share of the total each one is. One QUERY for the totals, one simple formula for the share.

By · Published November 8, 2026

The short answer: =QUERY(Orders!A:K, "select G, sum(J) where year(A) = 2026 group by G order by sum(J) desc label sum(J) 'Revenue'", 1), then divide each total by the sum for its share. In the sample data, Coffee is 67.2% of 2026 revenue.

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, then a share column

On a new tab, in A1. Column G is Category and J is Revenue:

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

That spills the categories into A2:A5 and their revenue into B2:B5. Type Share in C1, then in C2, copied down, divide by the total of the column:

=B2/SUM($B$2:$B$5)

Format C as a percent. The Total row in row 6 is =SUM(B2:B5) and =SUM(C2:C5), which should read 100%.

Example on sample data
fx=QUERY(Orders!A:K, "select G, sum(J) where year(A) = 2026 group by G order by sum(J) desc label sum(J) 'Revenue'", 1)
ABC
1CategoryRevenueShare
2Coffee$870,66267.2%
3Supplies$302,20823.3%
4Tea$105,8168.2%
5Equipment$17,5731.4%
6Total$1,296,259100.0%
SummaryOrders

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

Pivot table version: Insert → Pivot table, Category in Rows, Revenue in Values twice. Set the second one's Show as to % of grand total and you get the share column without a formula.

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("revenue by product category in 2026 with each category's share of total, plus a total row", "table")

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

Example on sample data
fx=QUIRIZ("revenue by product category in 2026 with each category's share of total, plus a total row", "table")
ABC
1CategoryRevenueShare
2Coffee$870,66267.2%
3Supplies$302,20823.3%
4Tea$105,8168.2%
5Equipment$17,5731.4%
6Total$1,296,259100.0%
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 sum sales by category in Google Sheets?
Use =QUERY(data, "select G, sum(J) group by G", 1) where G is the category column and J the amount. SUMIF also works if you list the categories yourself: =SUMIF(Orders!G:G, A2, Orders!J:J).
How do I show each category as a percent of total?
Divide each category's total by the sum of all totals, =B2/SUM($B$2:$B$5), and format as a percent. In a pivot table, set the value's Show as option to % of grand total.
Why does my QUERY show #REF!?
Something is sitting in the cells the result needs to spill into, often a total row you added below it. Move it, or leave empty rows under the QUERY.