Going Stellar

Home/Google Sheets reference

Google Sheets function · Statistical

MAXIFS in Google Sheets: syntax and examples

MAXIFS finds the largest number in a range, but only among the rows that pass your conditions. Add as many range and condition pairs as you need. All of them must match for a row to count.

Syntax

MAXIFS(range, criteria_range1, criterion1, [criteria_range2, criterion2], …)

Arguments

ArgumentTypeRequiredWhat it does
rangerangeyesThe cells to take the maximum from.
criteria_range1rangeyesThe range tested against criterion1. It must have the same size as range.
criterion1anyyesThe condition: a value, or a comparison such as ">100" or "Ch*".
criteria_range2, criterion2anynoMore range and condition pairs. A row counts only if every pair matches.

Examples

The examples use this table, starting in A1:

RegionProductSalesMonth
NorthLamp120Jan
SouthLamp95Jan
NorthChair310Feb
SouthChair280Feb
NorthLamp150Mar
=MAXIFS(C2:C6, A2:A6, "North")

Result: 310

Best sale in the North region.

Run in a Google Sheet (English US locale) on .

=MAXIFS(C2:C6, A2:A6, "North", B2:B6, "Lamp")

Result: 150

Two conditions at once: North and Lamp. Rows 2 and 6 qualify.

Run in a Google Sheet (English US locale) on .

=MAXIFS(C2:C6, C2:C6, "<300")

Result: 280

A comparison in quotes. The largest value below 300.

Run in a Google Sheet (English US locale) on .

=MAXIFS(C2:C6, B2:B6, "Ch*")

Result: 310

A wildcard: * stands for any text, so every product starting with Ch matches.

Run in a Google Sheet (English US locale) on .

=MAXIFS(C2:C6, A2:A6, "East")

Result: 0

No row matches. The result is 0, not an error.

Run in a Google Sheet (English US locale) on .

Common errors

  • Every criteria_range must have exactly the same size as range. A shorter one returns #VALUE!.
  • When no row matches, the result is 0, not an error or a blank. A 0 can also be a real maximum, so check the count with COUNTIFS if the difference matters.
  • Text conditions ignore case: "north" matches North.
  • A criterion without its range, such as MAXIFS(C2:C6, A2:A6), returns #N/A. Always pass the range and the condition as a pair.

Compared with Excel

Same syntax in Excel (2019 and Microsoft 365). Older Excel versions need an array formula with MAX and IF.

Questions and answers

How do I get the maximum for several conditions in MAXIFS?

Add more pairs after the first one: MAXIFS(C2:C6, A2:A6, "North", B2:B6, "Lamp"). A row is used only when all conditions are true.

Sources

  1. MAXIFS (Docs Editors Help)

Markdown version · All functions