formulastreak

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

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.

Q3 sales team · edit I1 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultI1 = $13,900
ABCDEFGHI
1RepRegionJulAugSepTargetBest North Sep$13,900
2Amara OseiNorth$12,400$13,100$11,800$36,000
3Ben FischerSouth$9,800$10,250$12,100$30,000
4Lina ChenEast$15,200$14,800$16,900$45,000
5Diego AlvarezWest$8,700$9,100$8,400$28,000
6Eva NovakNorth$11,200$12,600$13,900$36,000
7Farid HaddadSouth$13,300$12,900$14,100$39,000
8Grace KimEast$10,100$9,600$10,800$33,000
9Hugo MartinWest$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. 1. MAXIFS: Finds the largest value in E2:E9 on the rows where B2:B9 is equal to "North".
    • max_range = `E2:E9`: the numbers to search
    • range1 = `B2:B9`: the column to check
    • criteria1 = `"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

ArgumentRequiredWhat it is
max_rangeYesThe numbers to take the largest from.
criteria_range1YesThe range to test, the same size as max_range.
criteria1YesThe condition, written like SUMIFS criteria.
criteria_range2, criteria2NoMore 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

  • #NAME?: The file is open in Excel 2016 or older.
  • #VALUE!: The ranges aren't the same size.

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.

Practise MAXIFS on a live sheet

Lesson 20, COUNTIF, AVERAGEIFS and MAXIFS (Unit 5, Conditional totals), has 6 graded exercises, checked instantly, with steps and hints when you're stuck. Pro