Sub topic 15
Checking Results with SUMIFS and QUERY
Assume you already know how to create and read a pivot table. This chapter uses a source sheet named Sales with a header row and these columns:
| Column | Field |
|---|---|
| A | Sale ID |
| B | Region |
| C | Product |
| D | Date |
| E | Revenue |
A pivot table is a summary, so an incorrect source range, filter, or summarization setting can produce a plausible but wrong result. You can check important results with formulas that calculate from the source rows directly.
Use SUMIFS for a focused check
SUMIFS adds values that meet one or more conditions. For example, this formula calculates revenue for the West region:
=SUMIFS(Sales!E:E, Sales!B:B, "West")The first range, column E, contains the numbers to add. The second range, column B, contains the region condition. The text West selects only matching rows.
Compare this result with the West row in the pivot table. If the numbers differ, inspect the pivot's filters, source range, and value summarization.
You can add more conditions. For example, if column C contains products, this formula checks West revenue for the product named Keyboard:
=SUMIFS(Sales!E:E, Sales!B:B, "West", Sales!C:C, "Keyboard")Use SUMIFS when you need to verify one value or a small number of clearly defined values.
Use QUERY for a complete formula summary
QUERY returns a table based on a query expression. This formula groups the source data by region and adds the revenue for each region:
=QUERY(Sales!A1:E, "select B, sum(E) where B is not null group by B label sum(E) 'Total revenue'", 1)The range starts at A1 so the formula includes the headers. The final argument, 1, tells Sheets that the first row contains headers.
The query performs these actions:
- select B returns the Region field.
- sum(E) adds Revenue.
- where B is not null excludes blank regions.
- group by B creates one result row per region.
- label sum(E) 'Total revenue' gives the calculated column a readable name.
The QUERY output should match the pivot's region rows and revenue values. Row order may differ, so compare the region labels as well as the numbers.
Interpret differences
| Difference | Likely cause |
|---|---|
| SUMIFS is lower | The pivot excludes rows through a filter or uses a smaller source range |
| SUMIFS is higher | The pivot has a filter, or its source includes different columns or rows |
| QUERY has an extra region | The pivot filters that region or contains a stale configuration |
| Counts disagree | Blank cells, text numbers, or duplicate records affect the aggregation |
A pivot table may use a filter that SUMIFS does not reproduce. Make the formula's conditions match the pivot's conditions before deciding that either result is wrong.
Practice
Exercise
Which formula should you use to verify revenue for only the West region, and which formula should you use to produce a summary for every region?
Show answer
Use SUMIFS for the focused West check: =SUMIFS(Sales!E:E, Sales!B:B, "West"). Use QUERY for a grouped summary of every region.