Excel MAXIFS and MINIFS: the largest and smallest value by condition
MAXIFS and MINIFS find the largest and smallest value that meets your conditions: last purchase date, best price, and the trap of returning 0.
MAXIFS returns the largest value among rows that meet the conditions, and MINIFS returns the smallest. They are the “filtered” versions of MAX and MIN.
Questions: “What is Aziz’s biggest sale?”, “When did this client last buy?” (a date is a number too — the largest is the latest), “Where can we buy sugar cheapest?”. These used to require complex array formulas; now it’s one function.
MAXIFS and MINIFS are available in Excel 2019 and Microsoft 365.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Date | Manager | City | Amount | Question | Answer | |
| 2 | 03.01.2025 | Aziz | Tashkent | 1 250 000 | Aziz: largest | 1 250 000 | |
| 3 | 10.01.2025 | Dilnoza | Samarkand | 640 000 | Aziz: smallest | 480 000 | |
| 4 | 18.01.2025 | Javohir | Tashkent | 2 100 000 | |||
| 5 | 27.01.2025 | Aziz | Tashkent | 910 000 | |||
| 6 | 04.02.2025 | Dilnoza | Samarkand | 1 730 000 | |||
| 7 | 11.02.2025 | Aziz | Tashkent | 480 000 | |||
| 8 | 18.02.2025 | Javohir | Tashkent | 1 500 000 | |||
| 9 |
Syntax
=МАКСЕСЛИ(max_range; criteria_range1; criteria1; [criteria_range2; criteria2]; ...)
=МИНЕСЛИ(min_range; criteria_range1; criteria1; [criteria_range2; criteria2]; ...)
- max_range / min_range — the numbers to search for the largest or smallest:
D2:D8. It comes first — just like in SUMIFS. - criteria_range1, criteria1 — the first condition:
B2:B8,"Aziz". - criteria_range2, criteria2 … — extra conditions, up to 126 pairs.
Conditions are joined with “and”, and the ranges must be the same size. Conditions are written as in COUNTIFS: ">0", ">="&F1, "Tash*".
Step by step: entering MAXIFS
1
Select F2 for the result.
2
Формулы → Вставить функцию → type MAXIFS in the search box (category Statistical) and click OK.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Date | Manager | City | Amount | Question | Answer | |
| 2 | 03.01.2025 | Aziz | Tashkent | 1 250 000 | Aziz: largest | ||
| 3 | 10.01.2025 | Dilnoza | Samarkand | 640 000 | |||
| 4 | |||||||
| 5 |
3
Max_range — D2:D8, Criteria_range1 — B2:B8, Criteria1 — "Aziz". Click OK.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Date | Manager | City | Amount | Question | Answer | |
| 2 | 03.01.2025 | Aziz | Tashkent | 1 250 000 | Aziz: largest | ||
| 3 | 10.01.2025 | Dilnoza | Samarkand | 640 000 | |||
| 4 | |||||||
| 5 |
4
The result is 1,250,000. MINIFS is entered the same way: =МИНЕСЛИ(D2:D8;B2:B8;"Aziz").
Example 1: each client’s last purchase
A date is a number, so the largest date is the latest. MAXIFS finds the last purchase day for each client in the date column:
=МАКСЕСЛИ($A$2:$A$8;$B$2:$B$8;E2)
Give the result cell a date format — otherwise you’ll see a number like 45699. The first purchase comes from MINIFS, and days since the last one from =СЕГОДНЯ()-МАКСЕСЛИ(…). That’s how you spot clients who haven’t bought in a while.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Date | Client | Amount | Client | Last purchase | ||
| 2 | 03.01.2025 | Oila Market | 1 250 000 | Oila Market | 11.02.2025 | ||
| 3 | 11.01.2025 | Baraka Trade | 640 000 | Baraka Trade | 04.02.2025 | ||
| 4 | 18.01.2025 | Oila Market | 2 100 000 | Nur Shop | 18.02.2025 | ||
| 5 | 27.01.2025 | Nur Shop | 910 000 | ||||
| 6 | 04.02.2025 | Baraka Trade | 1 730 000 | ||||
| 7 | 11.02.2025 | Oila Market | 480 000 | ||||
| 8 | 18.02.2025 | Nur Shop | 1 500 000 | ||||
| 9 |
Example 2: the best price — ignoring zeros
In a supplier price table, 0 means “no offer”. Plain MINIFS returns exactly that zero as the “lowest price”. Add a condition on the price column itself:
=МИНЕСЛИ(C2:C7;A2:A7;"Sugar";C2:C7;">0")
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Product | Supplier | Price, 1 kg | Question | Answer | ||
| 2 | Sugar | Agro Trade | 13 500 | Sugar (plain) | 0 | ||
| 3 | Sugar | Ulgurji Plus | 0 | Sugar (>0) | 12 900 | ||
| 4 | Sugar | Sharq Savdo | 12 900 | Flour (>0) | 7 800 | ||
| 5 | Flour | Agro Trade | 7 800 | ||||
| 6 | Flour | Ulgurji Plus | 8 200 | ||||
| 7 | Flour | Sharq Savdo | 0 | ||||
| 8 |
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Date | Manager | City | Amount | Version | Result | |
| 2 | 03.01.2025 | Aziz | Tashkent | 1 250 000 | Bobur (none) | 0 | |
| 3 | 10.01.2025 | Dilnoza | Samarkand | 640 000 | Guarded | — | |
| 4 | 18.01.2025 | Javohir | Tashkent | 2 100 000 | |||
| 5 | 27.01.2025 | Aziz | Tashkent | 910 000 | |||
| 6 | 04.02.2025 | Dilnoza | Samarkand | 1 730 000 | |||
| 7 | 11.02.2025 | Aziz | Tashkent | 480 000 | |||
| 8 | 18.02.2025 | Javohir | Tashkent | 1 500 000 | |||
| 9 |
Pro level: who? when? how wide is the spread?
- Who made the biggest sale? MAXIFS gives the value; a lookup gives the name:
=ПРОСМОТРX(МАКСЕСЛИ(D2:D8;C2:C8;"Tashkent");D2:D8;B2:B8). Careful: if the same amount also appears in another city, XLOOKUP takes the first match. A robust version (Microsoft 365):=ПРОСМОТРX(1;(C2:C8="Tashkent")*(D2:D8=МАКСЕСЛИ(D2:D8;C2:C8;"Tashkent"));B2:B8). - The spread.
=МАКСЕСЛИ(…)-МИНЕСЛИ(…)— the gap between the largest and smallest order in a city. - A record for a period.
=МАКСЕСЛИ(D2:D8;A2:A8;">="&ДАТА(2025;2;1))— the largest sale since the start of February. - Last activity.
=СЕГОДНЯ()-МАКСЕСЛИ(A:A;B:B;E2)— how many days a client hasn’t bought; over 30 means it’s time to call.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Date | Manager | City | Amount | Question | Answer | |
| 2 | 03.01.2025 | Aziz | Tashkent | 1 250 000 | Tashkent: max | 2 100 000 | |
| 3 | 10.01.2025 | Dilnoza | Samarkand | 640 000 | Who? | Javohir | |
| 4 | 18.01.2025 | Javohir | Tashkent | 2 100 000 | Max − min | 1 620 000 | |
| 5 | 27.01.2025 | Aziz | Tashkent | 910 000 | February record | 1 730 000 | |
| 6 | 04.02.2025 | Dilnoza | Samarkand | 1 730 000 | |||
| 7 | 11.02.2025 | Aziz | Tashkent | 480 000 | |||
| 8 | 18.02.2025 | Javohir | Tashkent | 1 500 000 | |||
| 9 |
Try it in the simulator
Type =МАКСЕСЛИ(D2:D8;B2:B8;"Aziz") in F2. Then in F3 find the smallest order in Tashkent: =МИНЕСЛИ(D2:D8;C2:C8;"Tashkent").
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Date | Manager | City | Amount | Question | Answer | ||||||||||||||||||
| 2 | 45660 | Aziz | Tashkent | 1250000 | Aziz: largest | |||||||||||||||||||
| 3 | 45667 | Dilnoza | Samarkand | 640000 | Tashkent: smallest | |||||||||||||||||||
| 4 | 45675 | Javohir | Tashkent | 2100000 | ||||||||||||||||||||
| 5 | 45684 | Aziz | Tashkent | 910000 | ||||||||||||||||||||
| 6 | 45692 | Dilnoza | Samarkand | 1730000 | ||||||||||||||||||||
| 7 | 45699 | Aziz | Tashkent | 480000 | ||||||||||||||||||||
| 8 | 45706 | Javohir | Tashkent | 1500000 | ||||||||||||||||||||
| 9 | ||||||||||||||||||||||||
| 10 | ||||||||||||||||||||||||
| 11 | ||||||||||||||||||||||||
| 12 |
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.