Sub topic 6
Finding extremes with MIN and MAX
This chapter assumes you can enter formulas in Google Sheets and read cell addresses such as B2. It also assumes you know the range notation B2:B6 and the basic shape of a function call from earlier chapters. Here you will learn how MIN and MAX pick the smallest and largest values, which cells they skip, and what they return when there is nothing to compare.
What MIN and MAX do
MIN returns the smallest number among its arguments. MAX returns the largest. Both take one or more arguments, and each argument can be a single value, a cell, or a range.
=MIN(B2:B6)
=MAX(B2:B6)Suppose this data sits in A1:B6:
| Row | A | B |
|---|---|---|
| 1 | Product | Units sold |
| 2 | Apples | 120 |
| 3 | Bananas | 85 |
| 4 | Cherries | 240 |
| 5 | Dates | 60 |
| 6 | Elderberries | 175 |
=MIN(B2:B6) returns 60. =MAX(B2:B6) returns 240. Both functions return a value, not a location. They do not tell you that 240 belongs to Cherries. You need a lookup function for that, and a later chapter touches on the idea.
How the values are compared
Sheets compares the numbers arithmetically. It does not sort anything or change your data. You can picture it as a running champion: the function keeps the best value seen so far and replaces it whenever a better one appears.
MIN works the same way with the comparison reversed.
Negative numbers and zeros
MIN finds the value furthest to the left on the number line. With the values -5, 0, and 3, MIN returns -5 and MAX returns 3. A common mistake is expecting MIN to return the number closest to zero. It does not. To find the smallest size regardless of sign, you would need to take absolute values first, which is outside this chapter.
Zeros are real numbers, so they take part in the comparison. If one cell holds 0 and every other cell holds a positive number, MIN returns 0.
What MIN and MAX skip
When a range argument contains non-numbers, MIN and MAX ignore them. This is the same rule SUM, AVERAGE, and COUNT follow.
| Cell contents | Effect inside a range |
|---|---|
| Number | Compared |
| Zero | Compared, and can be the minimum |
| Empty cell | Skipped |
| Text such as `"n/a"` | Skipped |
| Number stored as text, such as `'45` | Skipped |
| TRUE or FALSE in a cell | Skipped |
| Error such as `#N/A` | The whole formula returns that error |
The last row matters most. Errors are not skipped. One #N/A in the range makes the whole MAX formula return #N/A. The "number stored as text" row is a frequent source of wrong answers, covered below.
Numbers stored as text
Imported data often arrives with numbers that Sheets treats as text. They usually align to the left of the cell, unlike real numbers. A range containing 10, 20, and a text "500" gives MAX of 20, because the "500" is skipped without any warning.
You can check how many cells are really numeric by comparing counts:
=COUNT(B2:B6)
=COUNTA(B2:B6)If COUNTA is larger than COUNT, some non-empty cells are not numbers. If you did not expect that, inspect them before trusting your MIN or MAX.
When there are no numbers
If the arguments contain no numbers at all, MIN and MAX return 0. They do not return an error. This is different from AVERAGE, which returns #DIV/0! in the same situation.
For example, if B2:B6 is completely empty, or contains only text, then both of these return 0:
=MIN(B2:B6)
=MAX(B2:B6)This can mislead you. A 0 result might be a real minimum or might mean "no data". When that distinction matters, guard the formula with COUNT:
=IF(COUNT(B2:B6)=0, "No data", MAX(B2:B6))The IF function checks whether the range holds any numbers. If it holds none, the formula shows the text. Otherwise it returns the maximum.
Several arguments at once
Like SUM, both functions accept several arguments. They compare across all of them together.
=MAX(B2:B6, D2:D6)
=MIN(B2:B6, 0)
=MAX(B2:B6, 100)The first finds the largest value across two separate ranges. The second returns the smaller of the minimum of B2:B6 and 0. The third gives a floor: the result is never below 100, because 100 is part of the comparison. This is a useful pattern:
MAX(value, 0)prevents a result from going below zero.MIN(value, 100)caps a result at 100.
Here is a small example. A bonus is 10% of sales but must not exceed 500:
=MIN(B2 * 0.1, 500)If B2 is 3000, then B2 * 0.1 is 300, so the result is 300. If B2 is 8000, the product is 800 and the result is capped at 500.
Dates and times
Sheets stores dates and times as numbers, so MIN and MAX work on them. MIN of a date range gives the earliest date and MAX gives the latest. The result may display as a plain number such as 46000 at first. If it does, apply a date format to the result cell with the Format menu.
=MAX(C2:C20)
=MIN(C2:C20)A frequent use is finding the most recent entry in a log, or the oldest one still open.
Combining with other functions
You can use MAX and MIN inside larger formulas. The range, the spread between the extremes, is one example:
=MAX(B2:B6) - MIN(B2:B6)With the sample data this gives 240 - 60 = 180. You can wrap the result in ROUND when the inputs have decimals, and in IFERROR when an error is possible:
=IFERROR(ROUND(MAX(B2:B6) - MIN(B2:B6), 2), "Check data")Functions are evaluated from the inside out. MAX and MIN run first, the subtraction follows, then ROUND, and IFERROR checks the final result.
Whole columns and moving data
=MAX(B:B) examines the whole of column B, so rows you add later are included. The header cell contains text, so it is skipped. Do not place the formula inside column B itself, or you create a circular reference, which Sheets reports as an error.
Common mistakes
- Expecting
MINto ignore zeros. Zeros count. If zeros stand for "not recorded", clear those cells or use a conditional function from a later chapter. - Trusting
0as a real answer. A0may mean there were no numbers. Check withCOUNT. - Leaving numbers as text. The cell is skipped. Convert the data, then re-check with
COUNTandCOUNTA. - Letting one error spoil the result. A single error cell in the range makes the whole formula fail. Find and fix the source cell, or isolate it from the range.
- Misreading the result as a position.
MAXreturns240, not "Cherries".
Related functions to know about
MINA and MAXA also exist. They handle text and logical values differently from MIN and MAX instead of skipping them. Read their help text in Sheets before using them, because the rules are easy to forget. For everyday numeric work, MIN and MAX are the right choice.
Exercise
Column B holds the values 12, 7, "n/a", an empty cell, and 0 (typed as a number). What do =MIN(B1:B5) and =MAX(B1:B5) return, and why?
Show answer
MIN returns 0 and MAX returns 12. The text "n/a" and the empty cell are skipped, but the number 0 is compared like any other number, so it is the smallest value.
Exercise
B2:B6 contains only text entries and no numbers. What does =MAX(B2:B6) return, and how would you make the formula show "No data" instead?
Show answer
It returns 0, because there are no numbers to compare. Use =IF(COUNT(B2:B6)=0, "No data", MAX(B2:B6)).
Exercise
A discount equals 15% of B2, but it must never be greater than 40. Write the formula.
Show answer
=MIN(B2 * 0.15, 40). MIN compares the computed discount with the cap of 40 and returns the smaller one.