Conditional totals function
MAXIFS function in Google Sheets and Excel
MAXIFS returns the largest number in a range on the rows that meet every condition.
Checked against Microsoft's and Google's documentation on · Example calculated on a live sheet
- Excel 2016
- Excel 2019
- Excel 2021
- Excel 2024
- Microsoft 365
- Google Sheets
Syntax
MAXIFS(max_range, criteria_range1, criteria1, [criteria_range2, criteria2], …)Arguments in [brackets] are optional. Google Sheets writes it MAXIFS(range, criteria_range1, criterion1, [criteria_range2, criterion2], …).
Example
=MAXIFS(E2:E9,B2:B9,"North") reads: Return the largest September figure E2:E9 among the rows whose region B2:B9 is North.
| A | B | C | D | E | F | G | H | I | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Rep | Region | Jul | Aug | Sep | Target | Best North Sep | $13,900 | |
| 2 | Amara Osei | North | $12,400 | $13,100 | $11,800 | $36,000 | |||
| 3 | Ben Fischer | South | $9,800 | $10,250 | $12,100 | $30,000 | |||
| 4 | Lina Chen | East | $15,200 | $14,800 | $16,900 | $45,000 | |||
| 5 | Diego Alvarez | West | $8,700 | $9,100 | $8,400 | $28,000 | |||
| 6 | Eva Novak | North | $11,200 | $12,600 | $13,900 | $36,000 | |||
| 7 | Farid Haddad | South | $13,300 | $12,900 | $14,100 | $39,000 | |||
| 8 | Grace Kim | East | $10,100 | $9,600 | $10,800 | $33,000 | |||
| 9 | Hugo Martin | West | $14,500 | $15,800 | $15,100 | $42,000 |
I1 shows $13,900: Eva's September beats Amara's $11,800.
How the spreadsheet calculates it
Finds the largest value in E2:E9 on the rows where B2:B9 is equal to "North".
- 1. MAXIFS: Finds the largest value in
E2:E9on the rows whereB2:B9is equal to"North".max_range=`E2:E9`: the numbers to searchrange1=`B2:B9`: the column to checkcriteria1=`"North"`: what it must match
More MAXIFS examples
=MAXIFS(E2:E9,B2:B9,"North")The best September figure in the North.=MAXIFS(B2:B13,C2:C13,"Mara Okafor")Mara's latest order date (format the cell as a date).=MAXIFS(E2:E9,B2:B9,"North",C2:C9,">12000")The best North September among reps who also sold over 12,000 in July.
Paste any of these into the formula explainer to see it step by step.
Tips
- Format the result like the column it comes from (a date column's maximum is the latest date).
- Check that a matching row exists with COUNTIFS when an empty result is possible.
- Use MINIFS with the same arguments for the smallest matching value.
- Keep max_range and every criteria range on the same rows, as with SUMIFS.
What MAXIFS is used for
The best month per salesperson, the latest date per customer (dates are numbers, so the largest is the latest), and the highest price paid per product.
Arguments
| Argument | Required | What it is |
|---|---|---|
| max_range | Yes | The numbers to take the largest from. |
| criteria_range1 | Yes | The range to test, the same size as max_range. |
| criteria1 | Yes | The condition, written like SUMIFS criteria. |
| criteria_range2, criteria2 | No | More range and condition pairs. |
Common mistakes
Using MAX with an IF around it: MAXIFS does it in one step.
Expecting it in Excel 2016 or older, where it doesn't exist (it arrived in Excel 2019).
Expecting a name back: MAXIFS returns the number. Look up who it belongs to with XLOOKUP or INDEX MATCH.
In Google Sheets
Google Sheets has MAXIFS and MINIFS with the same arguments.
Errors you may see with MAXIFS
Questions
What does MAXIFS return when nothing matches?
Microsoft's page doesn't say, and we haven't confirmed it, so check the count first with COUNTIFS if no match is possible.
Is there a MINIFS?
Yes, with the same arguments; it returns the smallest matching number.
How do I get the name that goes with the maximum?
Look the number up: XLOOKUP(MAXIFS(E2:E9, B2:B9, "North"), E2:E9, A2:A9). If two people tie, you get the first.
Does MAXIFS work with dates?
Yes. Dates are numbers, so the largest matching date is the latest one; format the result cell as a date to read it.
Sources
Official documentation the facts on this page were checked against.