Skip to content

MAXIFS

Returns the largest value in a range among the rows that meet one or more conditions, such as the biggest spend for one department.

Syntax

=MAXIFS(, , , [criteria_range2, criteria2], ...)

Statistical

Excel 2019, Excel 2021, Excel 2024, Excel for Microsoft 365 and Excel for the web. Not in the perpetual versions Excel 2016 and earlier.

Try it

Edit the formula in C11 or change the inputs. The sheet recalculates as you type.

C11
A
B
C
1
Dept
Quarter
Spend
2
IT
Q1
4,200
3
HR
Q1
1,800
4
IT
Q2
6,100
5
Ops
Q1
3,500
6
HR
Q2
2,200
7
IT
Q1
5,200
8
Ops
Q2
4,800
9
HR
Q2
2,900
10
11
Biggest IT spend
6,100

C11 =MAXIFS(C2:C9,A2:A9,"IT") returns 6,100

How MAXIFS works

MAXIFS finds the largest number among the rows that pass your tests. It answers "what is the biggest spend in IT?", "what is the longest delay for Grade A suppliers?" and "what is the latest date for this customer?" with one formula.

Argument order

The range to take the maximum from comes first, then pairs of test range and condition:

=MAXIFS(C2:C9, A2:A9, "IT", B2:B9, "Q1")

This is the same layout as AVERAGEIFS and COUNTIFS. Every criteria range must be the same size and shape as max_range, or MAXIFS returns #VALUE!.

Criteria

Conditions behave as they do in COUNTIF:

  • A plain value, such as "IT", matches whole cells and ignores case.
  • Comparisons go in quotes with the operator: ">100", "<>East".
  • Wildcards work on text: "Lap*", "?ccess".
  • A cell reference reads the current value, and ">"&E2 joins an operator to a cell.

All conditions must be true for a row to count (AND logic). You can test the max_range column itself: =MAXIFS(C2:C9, C2:C9, "<5000") returns the largest value below 5,000.

When nothing matches

If no row meets all the conditions, MAXIFS returns 0, not an error. That is easy to mistake for a real maximum. When it matters, check the count first: =IF(COUNTIFS(A2:A9,"Legal")=0,"No rows",MAXIFS(C2:C9,A2:A9,"Legal")).

Dates and text

MAXIFS works with dates, so =MAXIFS(B2:B50, A2:A50, E1) returns the latest date for the customer named in E1. It works on numbers only: it will not return the "largest" text.

Alternatives for older versions

Before Excel 2019, people used =MAX(IF(A2:A9="IT", C2:C9)), which needs Ctrl+Shift+Enter in Excel 2016 and earlier. In Microsoft 365 the same formula works as typed. Another route is AGGREGATE: =AGGREGATE(14, 6, C2:C9/(A2:A9="IT"), 1). If a workbook has to open in Excel 2016, avoid MAXIFS, because it shows #NAME? there.

The matching function for the smallest value is MINIFS. With no conditions, use MAX.

Arguments

max_range
The cells to take the maximum from, such as C2:C9.
criteria_range1
The first range to test, such as A2:A9. It must be the same size and shape as max_range.
criteria1
The first condition: a value, a cell reference or an expression such as ">100", "<>East" or "Lap*". Text and operators go in quotes.
criteria_range2, criteria2, ...optional
More pairs of range and condition, up to 126 pairs. A row is considered only when it passes every condition.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Largest value for one department

C11 =MAXIFS(C2:C9,A2:A9,"IT")

Result: 6,100

IT has three rows (4,200, 6,100 and 5,200). The largest is 6,100.

C11
A
B
C
1
Dept
Quarter
Spend
2
IT
Q1
4,200
3
HR
Q1
1,800
4
IT
Q2
6,100
5
Ops
Q1
3,500
6
HR
Q2
2,200
7
IT
Q1
5,200
8
Ops
Q2
4,800
9
HR
Q2
2,900
10
11
Biggest IT spend
6,100

C11 =MAXIFS(C2:C9,A2:A9,"IT") returns 6,100

Example 2

Two conditions

C11 =MAXIFS(C2:C9,A2:A9,"IT",B2:B9,"Q1")

Result: 5,200

Only two rows are both IT and Q1: 4,200 and 5,200. The larger is 5,200.

C11
A
B
C
1
Dept
Quarter
Spend
2
IT
Q1
4,200
3
HR
Q1
1,800
4
IT
Q2
6,100
5
Ops
Q1
3,500
6
HR
Q2
2,200
7
IT
Q1
5,200
8
Ops
Q2
4,800
9
HR
Q2
2,900
10
11
Biggest IT spend in Q1
5,200

C11 =MAXIFS(C2:C9,A2:A9,"IT",B2:B9,"Q1") returns 5,200

Example 3

Largest value under a limit

C11 =MAXIFS(C2:C9,C2:C9,"<5000")

Result: 4,800

The max_range can also be the range you test. Of the values below 5,000, the largest is 4,800.

C11
A
B
C
1
Dept
Quarter
Spend
2
IT
Q1
4,200
3
HR
Q1
1,800
4
IT
Q2
6,100
5
Ops
Q1
3,500
6
HR
Q2
2,200
7
IT
Q1
5,200
8
Ops
Q2
4,800
9
HR
Q2
2,900
10
11
Biggest spend under 5,000
4,800

C11 =MAXIFS(C2:C9,C2:C9,"<5000") returns 4,800

Example 4

No matching rows returns 0

C11 =MAXIFS(C2:C9,A2:A9,"Legal")

Result: 0

There is no Legal row, so MAXIFS returns 0 instead of an error. Check with COUNTIFS if that could be confused with a real zero.

C11
A
B
C
1
Dept
Quarter
Spend
2
IT
Q1
4,200
3
HR
Q1
1,800
4
IT
Q2
6,100
5
Ops
Q1
3,500
6
HR
Q2
2,200
7
IT
Q1
5,200
8
Ops
Q2
4,800
9
HR
Q2
2,900
10
11
Biggest Legal spend
0

C11 =MAXIFS(C2:C9,A2:A9,"Legal") returns 0

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In F2, return the longest time to fix for the team named in E2.

Answer in F2.

F2
A
B
C
D
E
F
1
Team
Priority
Hours to fix
Team
Longest fix
2
Billing
High
6
Billing
3
Access
Low
20
4
Billing
Low
14
High priority only
5
Network
High
9
6
Access
High
5
7
Billing
High
8
8
Network
Low
30
9
Access
Low
18

Common mistakes

  • When no row matches, MAXIFS returns 0, not an error. A zero can look like a real maximum, so check the count with COUNTIFS when it matters.
  • #VALUE! means the criteria ranges are not the same size as max_range. Make every range start and end on the same rows.
  • MAXIFS shows #NAME? in Excel 2016 and earlier. If the file has to open there, use MAX(IF(...)) or AGGREGATE instead.
  • A cell reference in quotes, such as "E2", is treated as the text E2. Write E2, or ">"&E2 to combine it with an operator.
  • Numbers stored as text in max_range are ignored, so MAXIFS can return a lower value than expected.

Questions people ask

Does MAXIFS work in Excel 2016?

No. MAXIFS was added in Excel 2019 and Microsoft 365. In Excel 2016 and earlier, use `=MAX(IF(A2:A9="IT",C2:C9))` confirmed with Ctrl+Shift+Enter.

Why does MAXIFS return 0?

Either the largest matching value really is 0, or no row met all the conditions. Check the spelling and spaces in your criteria, and test with COUNTIFS.

Can MAXIFS use OR logic?

Not directly. Take the larger of two results: `=MAX(MAXIFS(C2:C9,A2:A9,"IT"),MAXIFS(C2:C9,A2:A9,"HR"))`.

How do I find the second largest value that meets a condition?

Use LARGE with FILTER in Microsoft 365: `=LARGE(FILTER(C2:C9,A2:A9="IT"),2)`.

Learn MAXIFS in a real sheet.

MAXIFS is taught in Data analysis with formulas, lesson 6: MAXIFS and MINIFS. Each lesson is a short, graded exercise like the one above.