Math and statistics functions in Excel do the arithmetic that sits behind almost every report: totals, rounding, remainders, averages, rankings, and measures of how spread out a set of numbers is. SUM, ROUND, MOD, AVERAGE, MEDIAN, RANK and STDEV are the ones you will meet most. They are simple to call, and they are also where quiet mistakes happen: a total that includes hidden rows, an average that counts zeros, a rank that skips a number, or a rounding function that goes the “wrong” way for negative numbers.
This guide explains each group, shows the results side by side, and points out where the functions behave in a way that surprises people. Every result below was produced by running the formula in Microsoft Excel.
In this guide
- Operators and the order of calculation
- MOD, QUOTIENT and other basics
- Rounding functions
- Counting and averaging when cells are blank, zero or text
- Mean, median and mode
- Ranking and percentiles
- Spread: standard deviation and variance
- Hidden rows, filters and errors
- Why 0.1 + 0.2 is not quite 0.3
- Common mistakes
- Cheat sheet
- Try it yourself
- FAQ
The short version
- Excel follows the usual order: brackets, then powers, then
*and/, then+and-. Watch-2^2, which is 4 in Excel. ROUNDrounds halves away from zero.INTalways goes down,TRUNCjust cuts the decimals.AVERAGEignores blank cells and text but counts zeros. UseMEDIANwhen a few huge values distort the mean.SUBTOTAL(109, ...)andAGGREGATEcan skip hidden rows and errors;SUMcannot.
Operators and the order of calculation
Excel calculates brackets first, then powers (^), then multiplication and division from left to right, then addition and subtraction from left to right, and & (joining text) comes after the arithmetic. Two results here differ from what maths textbooks give, so they are worth knowing:
| Formula | Excel shows | Why |
|---|---|---|
| =2+3*4 | 14 | multiplication first |
| =(2+3)*4 | 20 | brackets first |
| =-2^2 | 4 | Excel applies the minus sign BEFORE the power, so it is (-2)^2 |
| =0-2^2 | -4 | a real subtraction gives the textbook answer |
| =2^3^2 | 64 | powers are calculated left to right: (2^3)^2, not 2^(3^2) |
| =(2^3)^2 | 64 | the same as above, written out |
| =200*10% | 20 | the % sign divides by 100, so 10% is 0.1 |
| =10-2-3 | 5 | left to right |
| =100/10/2 | 5 | left to right |
| =1+2&"3" | 33 | the sum is done first, then joined with the text 3 |
| =(-8)^(1/3) | -2 | an exponent of exactly 1/3 is treated as a cube root, which is defined for negatives |
| =(-8)^0.3333 | #NUM! | an inexact exponent on a negative number is an error |
MOD, QUOTIENT and other basics
MOD(number, divisor) is the remainder after division, and QUOTIENT(number, divisor) is the whole-number part of the division. MOD is the tool for “every 5th row”, odd or even tests, and cycling numbers. A1 holds 17 and A2 holds -7:
| Formula | Excel shows | Why |
|---|---|---|
| =MOD(A1,5) | 2 | 17 = 3 x 5 + 2 |
| =QUOTIENT(A1,5) | 3 | the whole number of 5s in 17 |
| =A1/5 | 3.4 | the ordinary division |
| =MOD(A2,3) | 2 | the result takes the sign of the divisor: -7 = -3 x 3 + 2 |
| =MOD(7,-3) | -2 | a negative divisor gives a negative remainder |
| =MOD(A1,2)=0 | FALSE | is 17 even? |
| =IF(MOD(A1,2)=0,"even","odd") | odd | |
| =POWER(2,10) | 1024 | the same as 2^10 |
| =SQRT(16) | 4 | |
| =ABS(A2) | 7 | distance from zero |
| =SIGN(A2) | -1 | -1, 0 or 1 |
| =MOD(A1,1) | 0 | |
| =MOD(2.75,1) | 0.75 | MOD with 1 keeps the decimal part |
| =PRODUCT(2,3,4) | 24 | multiplies everything |
Rounding functions
There are several ways to round, and they differ mostly for negative numbers and for numbers exactly halfway. Each column below is a number, each row is a function:
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Function | 2.5 | -2.5 | 2.567 | 1234.567 | 17 |
| 2 | ROUND(x,0) | 3 | -3 | 3 | 1235 | 17 |
| 3 | ROUND(x,1) | 2.5 | -2.5 | 2.6 | 1234.6 | 17 |
| 4 | ROUND(x,-2) | 0 | 0 | 0 | 1200 | 0 |
| 5 | ROUNDUP(x,0) | 3 | -3 | 3 | 1235 | 17 |
| 6 | ROUNDDOWN(x,0) | 2 | -2 | 2 | 1234 | 17 |
| 7 | INT(x) | 2 | -3 | 2 | 1234 | 17 |
| 8 | TRUNC(x) | 2 | -2 | 2 | 1234 | 17 |
| 9 | CEILING(x,5) | 5 | 0 | 5 | 1235 | 20 |
| 10 | FLOOR(x,5) | 0 | -5 | 0 | 1230 | 15 |
| 11 | MROUND(x,5) | 5 | #NUM! | 5 | 1235 | 15 |
Look at the -2.5 column. INT gives -3 but TRUNC gives -2. CEILING(-2.5, 5) is 0, because it rounds up towards positive numbers, and FLOOR(-2.5, 5) is -5. MROUND(-2.5, 5) is #NUM!, because MROUND refuses a negative number combined with a positive multiple. Check negative inputs before you rely on any of these.
| Function | What it does |
|---|---|
| ROUND(x, n) | nearest value with n decimals; halves go away from zero (2.5 becomes 3, -2.5 becomes -3); a negative n rounds to tens, hundreds and so on |
| ROUNDUP(x, n) | always away from zero |
| ROUNDDOWN(x, n) | always towards zero |
| INT(x) | always down to the next lower whole number, so -2.5 becomes -3 |
| TRUNC(x) | cuts off the decimals, so -2.5 becomes -2 |
| CEILING(x, s) and FLOOR(x, s) | up or down to a multiple of s |
| MROUND(x, s) | to the nearest multiple of s |
Rounding at the half point can look odd when the number is stored in binary. Excel rounds to the 15 digits it keeps, so it gives the answer most people expect:
| Formula | Excel shows | Why |
|---|---|---|
| =ROUND(A1,2) | 2.68 | 2.675 to two places gives 2.68 |
| =ROUND(A2,2) | 1.01 | |
| =ROUND(A3,0) | 1 | 0.5 rounds up |
| =ROUND(A4,0) | 2 | 1.5 rounds up |
| =ROUND(A5,0) | 3 | 2.5 also rounds up, not to the nearest even |
| =ROUND(A6,0) | 4 | 3.5 rounds up |
| =ROUND(-A3,0) | -1 | -0.5 rounds away from zero |
| =ROUND(A2,2)=1.01 | TRUE |
Counting and averaging when cells are blank, zero or text
Excel’s counting and averaging functions each treat blanks, text and zeros differently. A1:A5 hold 10, the text 20, an empty cell, 0 and 30:
| Formula | Excel shows | Why |
|---|---|---|
| =SUM(A1:A5) | 40 | the text 20 is ignored, so 10 + 0 + 30 |
| =COUNT(A1:A5) | 3 | counts only real numbers: 10, 0 and 30 |
| =COUNTA(A1:A5) | 4 | counts every cell that is not empty |
| =COUNTBLANK(A1:A5) | 1 | the empty cell |
| =AVERAGE(A1:A5) | 13.33333333 | ignores blanks and text, but counts the 0: 40 divided by 3 |
| =AVERAGEA(A1:A5) | 10 | counts text as 0: 40 divided by 4 |
| =SUM(A1:A5)/COUNTA(A1:A5) | 10 | not the same as AVERAGE |
| =SUM(A1:A5)/ROWS(A1:A5) | 8 | average including the blank as a row |
| =MAX(A1:A5) | 30 | |
| =MIN(A1:A5) | 0 | the zero counts as the minimum |
The practical point: a blank cell is not a zero. If blank means “no data yet”, AVERAGE is right. If blank should count as zero, type the zero.
Mean, median and mode
The mean (AVERAGE) adds everything and divides by the count. The median (MEDIAN) is the middle value once the numbers are sorted. The mode (MODE.SNGL) is the most frequent value. When a few values are extreme, the mean is dragged towards them and the median is not. Five employees earn 20, 25, 30, 35 and 500 thousand:
| Formula | Excel shows | Why |
|---|---|---|
| =AVERAGE(A1:A5) | 122 | pulled up by the 500 |
| =MEDIAN(A1:A5) | 30 | the middle salary, a better picture of a typical employee |
| =MAX(A1:A5)-MIN(A1:A5) | 480 | the range |
| =TRIMMEAN(A1:A5,0.4) | 30 | the mean after dropping the highest and lowest 20% of the values |
| Formula | Excel shows | Why |
|---|---|---|
| =MODE.SNGL(A1:A6) | 3 | 3 and 5 both occur twice; MODE.SNGL returns the first one it meets |
| =MEDIAN(A1:A6) | 4 | with six values, the median is the mean of the middle two, 3 and 5 |
| =AVERAGE(A1:A6) | 4.166666667 | |
| =COUNTIF(A1:A6,">=5") | 3 | how many are 5 or more |
Weighted average
When items count for different amounts, use SUMPRODUCT(values, weights) / SUM(weights). A plain average treats Maths, Science and English equally; the weighted one respects the weights in column C:
What the sheet shows
| A | B | C | |
|---|---|---|---|
| 1 | Subject | Marks | Weight |
| 2 | Maths | 80 | 50 |
| 3 | Science | 70 | 30 |
| 4 | English | 90 | 20 |
| 5 | Simple average | 80 | |
| 6 | Weighted average | 79 |
What is inside the cells (Show Formulas)
| A | B | C | |
|---|---|---|---|
| 1 | Subject | Marks | Weight |
| 2 | Maths | 80 | 50 |
| 3 | Science | 70 | 30 |
| 4 | English | 90 | 20 |
| 5 | Simple average | =AVERAGE(B2:B4) | |
| 6 | Weighted average | =SUMPRODUCT(B2:B4,C2:C4)/SUM(C2:C4) |
Ranking and percentiles
RANK.EQ(value, list, [order]) gives the position of a value in a list: 1 is the largest unless you pass 1 as the order. Equal values share a rank and the next rank is skipped. RANK.AVG gives tied values the average of their ranks:
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Score | RANK.EQ | RANK.AVG | Ascending |
| 2 | 85 | 3 | 3 | 3 |
| 3 | 92 | 1 | 1.5 | 4 |
| 4 | 78 | 4 | 4 | 2 |
| 5 | 92 | 1 | 1.5 | 4 |
| 6 | 60 | 5 | 5 | 1 |
Two students scored 92 and both are rank 1, so 85 is rank 3, not 2. LARGE and SMALL return the nth biggest or smallest value instead of a position, and QUARTILE.INC and PERCENTILE.INC cut the sorted list at a proportion:
| Formula | Excel shows | Why |
|---|---|---|
| =LARGE(A1:A5,1) | 92 | the largest |
| =LARGE(A1:A5,2) | 92 | a duplicate counts again: the second largest is also 92 |
| =LARGE(A1:A5,3) | 85 | |
| =SMALL(A1:A5,2) | 78 | second smallest |
| =QUARTILE.INC(A1:A5,1) | 78 | the first quartile: a quarter of the values lie below |
| =QUARTILE.INC(A1:A5,3) | 92 | the third quartile |
| =PERCENTILE.INC(A1:A5,0.9) | 92 | the 90th percentile |
Spread: standard deviation and variance
The standard deviation tells you how far values typically sit from the mean. Variance is the standard deviation squared. Excel has two versions, and the choice matters: use the .S versions (sample) when your numbers are a sample of a bigger group, and the .P versions (population) when they are the whole group. The list 2, 4, 4, 4, 5, 5, 7, 9 has a mean of 5:
| Formula | Excel shows | Why |
|---|---|---|
| =STDEV.P(A1:A8) | 2 | population: divides by n |
| =STDEV.S(A1:A8) | 2.138089935 | sample: divides by n – 1, so it is slightly larger |
| =ROUND(STDEV.S(A1:A8),2) | 2.14 | |
| =VAR.P(A1:A8) | 4 | the square of the population standard deviation |
| =VAR.S(A1:A8) | 4.571428571 | |
| =ROUND(VAR.S(A1:A8),2) | 4.57 | |
| =AVERAGE(A1:A8) | 5 | the mean |
Hidden rows, filters and errors
SUM adds every cell in the range, including cells in hidden rows. SUBTOTAL and AGGREGATE can skip them. In SUBTOTAL, function 9 is SUM and 109 is SUM that also ignores rows you hid by hand (both ignore rows removed by a filter). In AGGREGATE(function, options, range), option 5 ignores hidden rows and option 6 ignores errors. Here A1:A4 hold 10, 20, 30 and 40 and row 2 is hidden:
| Formula | Excel shows | Why |
|---|---|---|
| =SUM(A1:A4) | 100 | SUM does not care that a row is hidden |
| =SUBTOTAL(9,A1:A4) | 100 | 9 includes rows hidden by hand |
| =SUBTOTAL(109,A1:A4) | 80 | 109 leaves the hidden 20 out |
| =AGGREGATE(9,5,A1:A4) | 80 | option 5: ignore hidden rows |
| =AGGREGATE(9,6,A1:A4) | 100 | option 6 ignores errors, not hidden rows |
Errors spread: one error inside a SUM range makes the whole total an error. AGGREGATE with option 6 steps over them:
| Formula | Excel shows | Why |
|---|---|---|
| =SUM(A1:A3) | #N/A | one error spoils the total |
| =AGGREGATE(9,6,A1:A3) | 40 | sum of the rest |
| =AGGREGATE(1,6,A1:A3) | 20 | function 1 is AVERAGE: average of the rest |
Why 0.1 + 0.2 is not quite 0.3
Computers store most decimals in binary, where 0.1 and 0.2 cannot be written exactly. The tiny error is usually invisible because Excel shows 15 digits and cleans up the last steps, but it can show through in comparisons:
| Formula | Excel shows | Why |
|---|---|---|
| =0.1+0.2 | 0.3 | displays as 0.3 |
| =0.1+0.2=0.3 | TRUE | Excel rounds to 15 digits before comparing, so this is TRUE |
| =0.1+0.2-0.3 | 0 | displays 0 |
| =(0.1+0.2)-0.3 | 0 | also displays 0 … |
| =((0.1+0.2)-0.3)=0 | FALSE | … yet this test is FALSE: the stored result is a tiny leftover, not exactly 0 |
| =ROUND((0.1+0.2)-0.3,10)=0 | TRUE | round before comparing: this is the safe habit |
| =1/3*3=1 | TRUE |
The habit that protects you: when you compare the results of calculations with decimals, wrap them in ROUND(..., 10) (or a suitable number of places) first.
Common mistakes
Mistake 1: averaging averages
The average of two group averages is only right if the groups are the same size. Use SUMPRODUCT with the counts (a weighted average), or average the raw values.
Mistake 2: relying on the display for rounding
A cell formatted to two decimals still holds all the digits. Use ROUND when the stored value must change.
Mistake 3: expecting SUM to skip hidden rows
It does not. Use SUBTOTAL(109, ...) or AGGREGATE(9, 5, ...) for a total that follows what is visible.
Mistake 4: a blank that should be zero
AVERAGE ignores blank cells, so a missing zero raises the average. Type the 0 when the value is really zero.
Mistake 5: ranking ties
Tied values share a rank and the following rank is skipped. If you need unique ranks, add a tie-breaker such as +COUNTIF($A$2:A2, A2) - 1.
Cheat sheet
| Task | Formula | Note |
|---|---|---|
| Remainder | =MOD(17, 5) | sign follows the divisor |
| Whole-number division | =QUOTIENT(17, 5) | |
| Round to 2 decimals | =ROUND(A1, 2) | halves go away from zero |
| Round to nearest 5 | =MROUND(A1, 5) | CEILING and FLOOR go up or down |
| Round to hundreds | =ROUND(A1, -2) | a negative number of digits |
| Cut decimals | =TRUNC(A1) | INT rounds down instead |
| Average, skipping blanks | =AVERAGE(A1:A9) | zeros are counted |
| Typical value | =MEDIAN(A1:A9) | robust against extremes |
| Weighted average | =SUMPRODUCT(B2:B4, C2:C4) / SUM(C2:C4) | |
| Rank | =RANK.EQ(A2, $A$2:$A$9) | lock the list |
| nth largest | =LARGE(A1:A9, 2) | |
| Sample standard deviation | =STDEV.S(A1:A9) | STDEV.P for a whole population |
| Total of visible rows | =SUBTOTAL(109, A1:A9) | AGGREGATE(9, 5, …) also works |
Try it yourself
Work out each answer first, then open the solution.
1. A1 holds 47.32. Give the value rounded up to a whole number, rounded to one decimal, floored to a multiple of 10, and rounded to the nearest 5.
Show solution
| Formula | Excel shows |
|---|---|
| =ROUNDUP(A1,0) | 48 |
| =ROUND(A1,1) | 47.3 |
| =FLOOR(A1,10) | 40 |
| =MROUND(A1,5) | 45 |
| =INT(A1) | 47 |
2. Return the word even or odd for the numbers 14, 15 and -4.
Show solution
| Formula | Excel shows |
|---|---|
| =IF(MOD(A1,2)=0,"even","odd") | even |
| =IF(MOD(A2,2)=0,"even","odd") | odd |
| =IF(MOD(A3,2)=0,"even","odd") | even |
The test MOD(n, 2) = 0 works for negative numbers too, because MOD(-4, 2) is 0.
3. Salaries are 20, 25, 30, 35 and 500. Which measure, the average or the median, describes a typical salary better?
Show solution
| Formula | Excel shows |
|---|---|
| =AVERAGE(A1:A5) | 122 |
| =MEDIAN(A1:A5) | 30 |
The median (30). The average of 122 is higher than four of the five people earn, because of the single 500.
4. In the scores 85, 92, 78, 92 and 60, what rank does 85 get, and how could you get the same rank without RANK.EQ?
Show solution
| Formula | Excel shows | Why |
|---|---|---|
| =RANK.EQ(85,A1:A5) | 3 | two scores are higher, so rank 3 |
| =RANK.EQ(92,A1:A5) | 1 | |
| =COUNTIF(A1:A5,">"&85)+1 | 3 | count how many values are larger, then add one |
Frequently asked questions
How does Excel’s order of operations work?
Brackets first, then powers, then multiplication and division, then addition and subtraction, each left to right. One exception to remember: Excel applies a leading minus before a power, so =-2^2 gives 4.
What is the difference between ROUND, ROUNDUP, ROUNDDOWN and INT?
ROUND goes to the nearest value, ROUNDUP away from zero, ROUNDDOWN towards zero, and INT down to the next lower whole number, which differs from ROUNDDOWN for negative numbers.
How do I round to the nearest 5 or 10 in Excel?
=MROUND(A1, 5) for the nearest multiple, =CEILING(A1, 5) to round up to a multiple and =FLOOR(A1, 5) to round down.
What does MOD do in Excel?
MOD(number, divisor) returns the remainder after division. It is used for even and odd tests, every nth row, and wrapping numbers around.
What is the difference between AVERAGE and MEDIAN?
AVERAGE is the sum divided by the count. MEDIAN is the middle value of the sorted list. The median is less affected by very large or very small values.
Does AVERAGE include zeros and blank cells?
Zeros are included. Blank cells and text are ignored. AVERAGEA counts text as zero.
What is the difference between STDEV.S and STDEV.P?
STDEV.S is for a sample of a larger group and divides by n – 1. STDEV.P is for a whole population and divides by n.
How do I sum only visible cells after filtering?
Use SUBTOTAL(109, range) or AGGREGATE(9, 5, range). Plain SUM also adds the hidden and filtered-out rows.
Test yourself
Timed questions on Math, Rounding and Statistics, with an explanation for every answer.