MARGINOFERROR in Google Sheets: Range-Based Mean Margins
Use MARGINOFERROR in Google Sheets with a data range and confidence level, calculate interval endpoints and understand its documented t-based calculation.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: if A2:A6 contains 18, 19, 20, 21 and 22, =MARGINOFERROR(A2:A6,0.95) has expected result 1.9632431615. Add and subtract this margin from the sample mean, 20, to form the corresponding t-based mean interval.
Syntax and confidence level
=MARGINOFERROR(range, confidence)
The Google MARGINOFERROR reference documents a range and a confidence level strictly between 0 and 1. Enter 0.95 or 95% for 95% confidence, not 95.
This differs from CONFIDENCE.T, whose first argument is alpha, or one minus confidence. Google states the relationship explicitly:
=CONFIDENCE.T(1-confidence,STDEV(range),COUNT(range))
That expression explains the underlying range-based calculation: sample variability and numeric observation count determine the margin. Both MARGINOFERROR arguments are supplied; the reviewed page does not give an omitted-confidence default.
Worked example: measurements around a target
Enter this synthetic dataset:
| Cell | Measurement |
|---|---|
| A2 | 18 |
| A3 | 19 |
| A4 | 20 |
| A5 | 21 |
| A6 | 22 |
Put 0.95 in D1. In D2, calculate the mean:
=AVERAGE(A2:A6)
Expected result: 20. In D3, calculate the margin:
=MARGINOFERROR(A2:A6,D1)
Expected result: 1.9632431615. In D4 and D5, calculate the lower and upper bounds:
=D2-D3
=D2+D3
Expected results: 18.0367568385 and 21.9632431615. D3 is a half-width, not the full width and not the upper endpoint. The full width is approximately 3.9264863230.
The upper endpoint uses addition: mean plus margin. Subtracting the margin for both endpoints would duplicate the lower bound.
Independent calculation
For these five values, the sum of squared deviations from 20 is 10. Dividing by n minus 1 gives sample variance 2.5, so the sample standard deviation is approximately 1.5811388301. The standard error is that value divided by the square root of 5.
The 95% t critical value with 4 degrees of freedom is approximately 2.7764451052. Its product with the standard error gives 1.9632431615. This follows the t mean-interval equation in NIST’s confidence-limit reference.
As a separate documentation check, Google’s published range 8, 4, 3, 6 produces a margin of approximately 3.528, matching this same mathematical procedure. These are independently calculated checks, not a native test session.
Advanced application: compare confidence settings
Put 0.90, 0.95 and 0.99 in F2:F4. In G2, enter and fill down:
=MARGINOFERROR($A$2:$A$6,F2)
| Confidence | Expected margin |
|---|---|
| 0.90 | 1.5074433191 |
| 0.95 | 1.9632431615 |
| 0.99 | 3.2555867048 |
The same observations produce a wider interval at higher confidence. Formatting G2:G4 as percentages would usually be misleading: the margin has the same measurement units as the data, not probability units.
Changing every observation by adding 100 shifts the mean and both endpoints by 100 but leaves the margin unchanged. Multiplying every observation by 2 doubles the margin to approximately 3.9264863230. These mathematical invariance checks are useful for detecting a unit conversion error in an analysis sheet.
What the result can and cannot establish
Google identifies normally distributed continuous data and large-sample surveys as relevant contexts. A confidence interval for a mean still depends on suitable sampling and model assumptions. Five neatly spaced demonstration values are not evidence that a real process satisfies those assumptions.
The margin is not a guarantee for the next measurement, a correction for sampling bias or a universal survey-percentage margin. For a fixed population mean, confidence describes repeated-sampling performance of the method, not a fresh probability assigned to the fixed mean after observing this particular sample.
A small margin can coexist with systematic bias. Repeated copies of the same observation do not create new independent information just because COUNT becomes larger.
Errors and troubleshooting
Check that confidence is between 0 and 1 and that the intended numeric observations are included. For the demonstrated t calculation, at least two observations and positive sample variability avoid degenerate cases. Native behavior for empty ranges, a single observation, zero variability or error cells was not established by the reviewed page.
Google’s documented identity uses STDEV and COUNT. Do not replace missing values with zeros merely to make the range rectangular, and do not calculate a mean from one filtered subset while taking the margin from another.
Availability and verification
MARGINOFERROR is documented in current rolling Google Sheets. Original introduction date, first release and last functioning numbered version were not established. No assumption of an identically named function in another spreadsheet is needed.
NOT_TESTED_IN_GOOGLE_SHEETS. Google and NIST pages were inspected on October 17, 2026. Original means, sample deviations, critical values, interval bounds and scaling checks were independently calculated. No native execution or screenshot is claimed.
Related published guides: AVERAGE, STDEV.S, COUNT and ROUND.