Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Google Sheets Formula Category Comparison

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

You compare categories in Google Sheets by using COUNTIF, SUMIF, COUNTIFS or SUMIFS to pull totals and counts per label, then wrapping them in IF formulas when you need a straight yes/no verdict. The shortest working approach: build a unique list of your categories with =UNIQUE(range), then put =SUMIF(category_range, A2, value_range) beside it. That gives you a side-by-side comparison table you can sort, chart and filter without touching pivot tables.

This guide covers the formulas you actually need, how they behave on text versus numbers, and where things usually break.

What You'll Need

  • A Google Sheet with one column holding category labels (text or dates) and at least one numeric column you want to compare.
  • Edit access to the sheet, so you can type formulas.
  • A clean category column: no trailing spaces, no mixed capitalisation, no merged cells. Formulas match text exactly, so Home and home are two different categories.
  • An empty area of the sheet, or a new tab, to hold the comparison table.

Step-by-Step

  1. Set up a real table. Put your data in a range with headers in row 1 and no blank rows inside it, for example column A as Category, column B as Revenue. Blank rows and subtotal rows are the most common reason comparison formulas give wrong answers.
  2. Get the category list. In an empty cell away from your data, type =UNIQUE(A2:A100). This spills one clean list of every distinct category. Adjust the range to cover your data. If you prefer a manual list, type the category names by hand into a column instead.
  3. Count each category. In the next column beside your unique list, in the first data row (say cell D2), enter =COUNTIF($A$2:$A$100, C2). The dollar signs lock the source range so it does not slide as you drag the formula down.
  4. Add the value total. In E2, enter =SUMIF($A$2:$A$100, C2, $B$2:$B$100). The first range is the categories, the second argument is the category to match, and the third range is the numbers to add. SUMIF requires the sum range to be the same height as the criteria range.
  5. Add an average. In F2, enter =IFERROR(AVERAGEIF($A$2:$A$100, C2, $B$2:$B$100), "") if you want the typical value per category rather than the total. AVERAGEIF returns an error when a category has no numeric entries, so IFERROR gives you a blank instead.
  6. Drag the formulas down. Select D2:F2 and drag the fill handle down to the last row of your unique list. Every row now compares one category.
  7. Add a share-of-total column. In G2, enter =E2/SUM($E$2:$E$20) and format the column as percent. That turns raw totals into a comparable split across categories.
  8. Compare two conditions at once. Where you need to slice by category plus something else (month, region, status), use COUNTIFS: =COUNTIFS($A$2:$A$100, C2, $H$2:$H$100, "Q1"). Add each extra condition as another pair of ranges and values. SUMIFS works the same way, with the sum range first: =SUMIFS($B$2:$B$100, $A$2:$A$100, C2, $H$2:$H$100, "Q1").
  9. Write a verdict column. If you just want to flag winners, add =IF(E2=MAX($E$2:$E$20), "Top", "") or compare one category to another directly: =IF(E2>E3, "Higher", "Lower"). Use =EXACT(C2, D2) when you need a case-sensitive text comparison.
  10. Sort and format. Select your comparison table and use Data > Sort range to rank by total or count. Freeze the header row with View > Freeze so it stays visible while you scroll. Menu labels can differ slightly by version and region.

Common Mistakes

  • Unequal range sizes. SUMIF needs the criteria range and sum range to be the same height. If they are not, it returns results from shifted rows or throws an error.
  • Forgetting absolute references. Typing A2:A100 instead of $A$2:$A$100 means the range moves as you fill the formula down, so lower rows read the wrong data.
  • Hidden spaces and mixed case. COUNTIF and SUMIF ignore case, so Home and HOME match. They do not ignore spaces, so Home with a trailing space becomes a separate category. Clean up with =TRIM() in a helper column.
  • Numbers stored as text. If totals come back as zero, the value column is probably formatted as plain text. Reformat it as a number or multiply a helper column by 1.
  • Criteria that look like operators. Searching for a literal >, * or ? needs escaping, because wildcards and comparison operators are read as syntax inside the criteria string.
  • Counting subtotal rows. If your sheet has a total row inside the range, it gets counted as its own category. Point the ranges only at raw data.

Tips

  • Name your ranges (Data > Named ranges) so formulas read as =SUMIF(Category, C2, Revenue) instead of a wall of cell addresses. Named ranges also survive inserting rows.
  • Use =COUNTIF(range, "*text*") to count categories containing a word, and ? for a single unknown character.
  • Wrap the whole table in a pivot table instead if you need three or more breakdowns at once: select the data, then Insert > Pivot table, put the category in Rows and the numbers in Values. Pivot tables are faster to explore; formulas are better when the table must update in place and feed a dashboard.
  • For categories that must include all rows even with no matching number, COUNTIF returns 0 cleanly while SUMIF also returns 0, so no cleanup is needed.
  • Format the comparison table as a chart with Insert > Chart to spot which category leads at a glance.

Troubleshooting

All results are zero. Check that the criteria range really contains the category labels and that the values are numbers, not text. Click a value cell and look at the alignment: text usually sits left, numbers right.

You get #VALUE! or a range error. Confirm the ranges are the same size and that the criteria argument is a single cell reference, not a whole range.

Duplicate categories appear. Your source has trailing spaces or hidden characters. Add a helper column with =TRIM(A2), fill it down, and point the formulas at that column.

The unique list will not spill. UNIQUE needs empty cells below and to the right. Clear the block underneath it; if a stray value is in the way you will see #REF!.

Results are stale after you edit data. Check for a manual calculation setting or a filter hiding rows. Unhide all rows and recalculate by editing any cell. If your formulas read an imported range, refresh the import.

Wildcards are not working. Wildcards only work with text criteria. If the criteria cell holds a number, wildcards are treated literally.

Frequently Asked Questions

Can I compare categories with different capitalisation?

Yes. COUNTIF, SUMIF and their plural versions are not case-sensitive. Use EXACT only when case matters, and note EXACT returns TRUE or FALSE rather than a count.

What is the difference between COUNTIF and COUNTIFS?

COUNTIF takes one condition. COUNTIFS takes two or more pairs of ranges and criteria and counts rows that meet all of them, such as category plus month.

Can I compare categories across two different sheets?

Yes. Reference another tab as Sheet1!A2:A100 inside any of these formulas. Enclose the sheet name in single quotes if it contains a space, like 'Q1 Data'!A2:A100.

Why does SUMIF return 0 for a category I can see in the data?

Almost always a text mismatch: a trailing space, a non-breaking space, or the label typed slightly differently in the criteria cell. Copy the label straight from the data instead of retyping it.

Do these formulas work in Excel too?

COUNTIF, SUMIF, COUNTIFS, SUMIFS and AVERAGEIF exist in Excel with the same argument order. UNIQUE and the spill behaviour are newer and are not available in older Excel versions.