New: 6 free SQL practice datasets with 300+ questions — try the SQL Compiler →
Excel

Excel ROUND, MOD, RANK and AVERAGE Functions

Excel math and statistics functions explained: order of calculation, ROUND, MOD, AVERAGE, MEDIAN, RANK, STDEV and SUBTOTAL, with real results and traps.

Upskly AI Team September 27, 2026 13 min read
Excel ROUND, MOD, RANK and AVERAGE Functions

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

The short version

  • Excel follows the usual order: brackets, then powers, then * and /, then + and -. Watch -2^2, which is 4 in Excel.
  • ROUND rounds halves away from zero. INT always goes down, TRUNC just cuts the decimals.
  • AVERAGE ignores blank cells and text but counts zeros. Use MEDIAN when a few huge values distort the mean.
  • SUBTOTAL(109, ...) and AGGREGATE can skip hidden rows and errors; SUM cannot.

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:

Order of calculation
FormulaExcel showsWhy
=2+3*414multiplication first
=(2+3)*420brackets first
=-2^24Excel applies the minus sign BEFORE the power, so it is (-2)^2
=0-2^2-4a real subtraction gives the textbook answer
=2^3^264powers are calculated left to right: (2^3)^2, not 2^(3^2)
=(2^3)^264the same as above, written out
=200*10%20the % sign divides by 100, so 10% is 0.1
=10-2-35left to right
=100/10/25left to right
=1+2&"3"33the sum is done first, then joined with the text 3
=(-8)^(1/3)-2an 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:

MOD and its relatives
FormulaExcel showsWhy
=MOD(A1,5)217 = 3 x 5 + 2
=QUOTIENT(A1,5)3the whole number of 5s in 17
=A1/53.4the ordinary division
=MOD(A2,3)2the result takes the sign of the divisor: -7 = -3 x 3 + 2
=MOD(7,-3)-2a negative divisor gives a negative remainder
=MOD(A1,2)=0FALSEis 17 even?
=IF(MOD(A1,2)=0,"even","odd")odd
=POWER(2,10)1024the same as 2^10
=SQRT(16)4
=ABS(A2)7distance from zero
=SIGN(A2)-1-1, 0 or 1
=MOD(A1,1)0
=MOD(2.75,1)0.75MOD with 1 keeps the decimal part
=PRODUCT(2,3,4)24multiplies 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:

Rounding functions applied to five numbers (row 1)
ABCDEF
1Function2.5-2.52.5671234.56717
2ROUND(x,0)3-33123517
3ROUND(x,1)2.5-2.52.61234.617
4ROUND(x,-2)00012000
5ROUNDUP(x,0)3-33123517
6ROUNDDOWN(x,0)2-22123417
7INT(x)2-32123417
8TRUNC(x)2-22123417
9CEILING(x,5)505123520
10FLOOR(x,5)0-50123015
11MROUND(x,5)5#NUM!5123515

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.

How the rounding functions differ
FunctionWhat 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:

ROUND on halves
FormulaExcel showsWhy
=ROUND(A1,2)2.682.675 to two places gives 2.68
=ROUND(A2,2)1.01
=ROUND(A3,0)10.5 rounds up
=ROUND(A4,0)21.5 rounds up
=ROUND(A5,0)32.5 also rounds up, not to the nearest even
=ROUND(A6,0)43.5 rounds up
=ROUND(-A3,0)-1-0.5 rounds away from zero
=ROUND(A2,2)=1.01TRUE

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:

The same five cells, ten functions
FormulaExcel showsWhy
=SUM(A1:A5)40the text 20 is ignored, so 10 + 0 + 30
=COUNT(A1:A5)3counts only real numbers: 10, 0 and 30
=COUNTA(A1:A5)4counts every cell that is not empty
=COUNTBLANK(A1:A5)1the empty cell
=AVERAGE(A1:A5)13.33333333ignores blanks and text, but counts the 0: 40 divided by 3
=AVERAGEA(A1:A5)10counts text as 0: 40 divided by 4
=SUM(A1:A5)/COUNTA(A1:A5)10not the same as AVERAGE
=SUM(A1:A5)/ROWS(A1:A5)8average including the blank as a row
=MAX(A1:A5)30
=MIN(A1:A5)0the 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:

Salaries in thousands
FormulaExcel showsWhy
=AVERAGE(A1:A5)122pulled up by the 500
=MEDIAN(A1:A5)30the middle salary, a better picture of a typical employee
=MAX(A1:A5)-MIN(A1:A5)480the range
=TRIMMEAN(A1:A5,0.4)30the mean after dropping the highest and lowest 20% of the values
The list 2, 3, 3, 5, 5, 7
FormulaExcel showsWhy
=MODE.SNGL(A1:A6)33 and 5 both occur twice; MODE.SNGL returns the first one it meets
=MEDIAN(A1:A6)4with six values, the median is the mean of the middle two, 3 and 5
=AVERAGE(A1:A6)4.166666667
=COUNTIF(A1:A6,">=5")3how 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

ABC
1SubjectMarksWeight
2Maths8050
3Science7030
4English9020
5Simple average80
6Weighted average79

What is inside the cells (Show Formulas)

ABC
1SubjectMarksWeight
2Maths8050
3Science7030
4English9020
5Simple average=AVERAGE(B2:B4)
6Weighted 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:

ABCD
1ScoreRANK.EQRANK.AVGAscending
285333
39211.54
478442
59211.54
660551

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:

Scores 85, 92, 78, 92 and 60
FormulaExcel showsWhy
=LARGE(A1:A5,1)92the largest
=LARGE(A1:A5,2)92a duplicate counts again: the second largest is also 92
=LARGE(A1:A5,3)85
=SMALL(A1:A5,2)78second smallest
=QUARTILE.INC(A1:A5,1)78the first quartile: a quarter of the values lie below
=QUARTILE.INC(A1:A5,3)92the third quartile
=PERCENTILE.INC(A1:A5,0.9)92the 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:

Population versus sample
FormulaExcel showsWhy
=STDEV.P(A1:A8)2population: divides by n
=STDEV.S(A1:A8)2.138089935sample: divides by n – 1, so it is slightly larger
=ROUND(STDEV.S(A1:A8),2)2.14
=VAR.P(A1:A8)4the square of the population standard deviation
=VAR.S(A1:A8)4.571428571
=ROUND(VAR.S(A1:A8),2)4.57
=AVERAGE(A1:A8)5the 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:

A total with a hidden row
FormulaExcel showsWhy
=SUM(A1:A4)100SUM does not care that a row is hidden
=SUBTOTAL(9,A1:A4)1009 includes rows hidden by hand
=SUBTOTAL(109,A1:A4)80109 leaves the hidden 20 out
=AGGREGATE(9,5,A1:A4)80option 5: ignore hidden rows
=AGGREGATE(9,6,A1:A4)100option 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:

A range containing #N/A
FormulaExcel showsWhy
=SUM(A1:A3)#N/Aone error spoils the total
=AGGREGATE(9,6,A1:A3)40sum of the rest
=AGGREGATE(1,6,A1:A3)20function 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:

Floating point in Excel
FormulaExcel showsWhy
=0.1+0.20.3displays as 0.3
=0.1+0.2=0.3TRUEExcel rounds to 15 digits before comparing, so this is TRUE
=0.1+0.2-0.30displays 0
=(0.1+0.2)-0.30also displays 0 …
=((0.1+0.2)-0.3)=0FALSE… yet this test is FALSE: the stored result is a tiny leftover, not exactly 0
=ROUND((0.1+0.2)-0.3,10)=0TRUEround before comparing: this is the safe habit
=1/3*3=1TRUE

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

Math and statistics cheat sheet
TaskFormulaNote
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
A1 holds 47.32
FormulaExcel 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
A1 = 14, A2 = 15, A3 = -4
FormulaExcel 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
Five salaries
FormulaExcel 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
Ranking 85 and 92
FormulaExcel showsWhy
=RANK.EQ(85,A1:A5)3two scores are higher, so rank 3
=RANK.EQ(92,A1:A5)1
=COUNTIF(A1:A5,">"&85)+13count 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.

Take the Quiz
Upskly AI Team
Learning made simple
Scroll to Top