Wize Management Information Systems Textbook > Spreadsheet Analysis with Excel

Conditional Aggregation Functions (COUNTIFS, SUMIFS)

Conditional Aggregation Functions

Conditional Aggregation Functions summarize records that meet specified conditions. In Excel, COUNTIFS answers questions such as how many orders are paid, while SUMIFS answers questions such as how much those orders are worth. You keep the detailed records and calculate a summary from the qualifying rows. Start by identifying what one row represents and whether your answer should be a count or a total.

Choose the output

Conditional aggregation means counting records or adding values only when specified conditions are satisfied. The basic rule is:


Include a record only when every supplied criterion is satisfied.\text{Include a record only when every supplied criterion is satisfied.}


Business question

Function

Contribution from each matching row

How many orders qualify?

COUNTIFS

One order

What is their total revenue?

SUMIFS

That order's revenue


For example, suppose each row in this worksheet represents one order. The amounts are numeric values in Canadian dollars.


Row

A: Branch

B: Status

C: Revenue (CAD)

2

West

Paid

160

3

West

Pending

290

4

East

Paid

220

5

West

Paid

340


The Paid orders from West occupy rows 2 and 5. Counting them gives two orders; adding their revenue gives CAD 500. These outputs describe the same selected records but measure different things.

Pair each range with its criterion

A criterion is a condition that a value must satisfy. Supply each criterion immediately after the range it tests. For the example above, the count is:


=COUNTIFS(A2:A5,"West",B2:B5,"Paid")


The first pair tests branch; the second tests payment status. Both conditions apply to each record. To add the corresponding revenue, put the sum range first:


=SUMIFS(C2:C5,A2:A5,"West",B2:B5,"Paid")


Matching revenue=160+340=500 CAD\text{Matching revenue}=160+340=500\ \text{CAD}


These formulas use English function names and commas as argument separators. Some regional settings use semicolons instead.


Intended condition

Criterion entered in the formula

Status equals Paid

"Paid"

Amount is at least 250

">=250"

Amount is below 250

"<250"

Amount is at least the value in H2

">="&H2


Quotation marks enclose literal text and comparison expressions. When a comparison uses a cell's value, the ampersand joins the quoted operator to the cell reference. Writing ">=250" fixes the threshold; writing ">="&H2 lets the threshold follow H2.



Align the records and check the logic

All ranges in either function must have matching dimensions. For a table with one record per row, they should also start and finish on the same record. Pairing A2:A5 with C3:C6 shifts the amounts by one row even though both ranges contain four cells.


Cells in three spreadsheet columns are connected across their corresponding rows.



Multiple criteria within one function mean all conditions apply together. Testing one Branch column for both East and West therefore selects no records when each order has exactly one branch.


For East or West, add separate conditional results. Those categories do not overlap, so each qualifying order contributes once. If the conditions can overlap, adding their results counts the shared records twice; subtract the result for the overlap once.


Check a small set of records manually. Confirm boundary values, such as an amount exactly equal to a minimum. A plausible total alone does not establish that the correct records were selected.

What to remember

  • COUNTIFS counts qualifying records; SUMIFS adds their values.
  • Put the SUMIFS sum range first, then range–criterion pairs.
  • Every criterion within one function applies to the same record.
  • Align ranges and check whether alternative groups overlap.

Example: Summarize paid branch orders

An office supplier records one order per row in Excel. Column C contains numeric order values in Canadian dollars. Cell G2 contains 400, and H2 contains 800; both are editable numeric thresholds.


Row

A: Branch

B: Status

C: Order value (CAD)

2

West

Paid

480

3

East

Paid

620

4

West

Pending

360

5

West

Paid

750

6

West

Paid

250

7

East

Pending

540


a) Write a formula to count Paid West orders and determine the result.


The output is a count of orders, so use COUNTIFS. Pair the branch range with "West" and the status range with "Paid":


=COUNTIFS(A2:A7,"West",B2:B7,"Paid")


Check both conditions on each row. Rows ________ are West and Paid. Row 4 is West but Pending, while rows 3 and 7 belong to East.


Matching orders=1+1+1=3\text{Matching orders}=1+1+1=3


The result is three orders. Their different monetary values do not affect this count.


b) Write a formula to total the value of Paid West orders and calculate the total.


The selected records stay the same, but the output is now money. Use SUMIFS with C2:C7 as its first argument, followed by the same range–criterion pairs:


=SUMIFS(C2:C7,A2:A7,"West",B2:B7,"Paid")


All ranges cover rows 2–7, so each order value is matched with its own branch and status. Add the values from qualifying rows 2, 5, and 6:


Total value=480+750+250=1480 CAD\begin{aligned} \text{Total value}&=480+750+250\\ &=1480\ \text{CAD} \end{aligned}


The total value of Paid West orders is CAD 1,480. Counting three records would answer a different business question.


c) Total Paid West order values that are at least G2 but below H2. Use both cell references in the formula and calculate the result for the current thresholds.


Keep the branch and status requirements. Add two comparisons on the order-value range: an inclusive lower bound and an exclusive upper bound. The ampersand joins each operator to its threshold cell:


=SUMIFS(C2:C7,A2:A7,"West",B2:B7,"Paid",C2:C7,">="&G2,C2:C7,"<"&H2)


The current thresholds require an individual order value of at least CAD 400 and below CAD 800. Among the Paid West orders, CAD ________ and CAD ________ qualify; CAD 250 is below the lower bound.


Total within the band=480+750=1230 CAD\begin{aligned} \text{Total within the band}&=480+750\\ &=1230\ \text{CAD} \end{aligned}


The result is CAD 1,230. An order exactly equal to CAD 400 would qualify, while one exactly equal to CAD 800 would not. Changing G2 or H2 changes the comparison without editing the formula.

An online retailer stores one order per row in rows 2–81. Column B contains the sales channel, column C contains shipping status, and column D contains revenue in Canadian dollars.


A manager asks how many orders have channel Online and status Shipped. Which approach answers this request?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A warehouse uses COUNTIFS and SUMIFS to summarize product codes stored as text. A wildcard represents characters within a text criterion. Match each quoted Excel criterion to the complete product codes it accepts. Assume the codes contain no leading or trailing spaces.

Match each term
A.

Consists of BK followed by a literal asterisk and nothing else

B.

Begins with BK, followed by zero or more characters

C.

Begins with BK, followed by exactly one character

D.

Contains BK anywhere, with any number of characters before or after it

"*BK*"\text{"*BK*"}

"BK *"\text{"BK~*"}

"BK?"\text{"BK?"}

"BK*"\text{"BK*"}

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A distributor records one invoice per row in rows 2–42. Column B contains the branch, and column D contains numeric invoice amounts in Canadian dollars. Cell G2 currently contains 600.


The analyst needs the total value of North invoices whose individual amounts are at least the threshold in G2. The formula must continue to work when G2 changes. Which formula meets both requirements?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice