You find the trend line equation by calculating slope m and intercept b, then writing y = mx + b. In Excel, right-click any data point and choose Add Trendline, then tick "Display Equation on chart." In Google Sheets, open the Chart Editor's Customize tab, expand Series, and check "Show trendline label." By hand, m = Σ[(xᵢ − x̄)(yᵢ − ȳ)] ÷ Σ(xᵢ − x̄)², and b = ȳ − m·x̄.
Those three paths cover almost every situation a student, analyst, or lab worker runs into. What follows sticks to stable, checkable procedure: the arithmetic, the menu names Microsoft and Google have used for years, and the failure modes that make a chart show a line with no equation at all.
What the Trend Line Equation Actually Tells You
A trend line equation is the formula for the straight line that best fits your points under the least-squares rule, which means it minimizes the sum of squared vertical distances from each point to the line. The slope m states how much y changes for each one-unit increase in x. The intercept b states the predicted y when x equals zero, which is sometimes meaningful and sometimes pure bookkeeping.
Least squares is not the only fitting rule in existence. Excel's LINEST function and the chart trendline both use ordinary least squares, while a robust regression such as R's MASS package rlm down-weights outliers. If your data has one badly mismeasured point, the two approaches can produce visibly different slopes, so know which one your software ran before you publish a number.
The equation is a description of your sample, not a law of nature. A slope of 2.4 in a calibration curve means the plotted standards averaged 2.4 units of response per unit of concentration. Whether that slope transfers to tomorrow's run depends on your instrument, your reagents, and your technique, none of which the equation can see.
Watch the order of operations when you read results off a chart. Excel labels the line y = 2.4x + 0.8, which means y is the vertical axis variable and x is the horizontal one. If you plotted concentration on the vertical axis and absorbance on the horizontal, your "slope" is the reciprocal of the calibration factor you actually want. Swapping axes changes the equation and, because least squares minimizes vertical rather than perpendicular distances, it doesn't simply invert the original slope.
Read the Equation Straight Off an Excel Chart
1: Select your scatter chart and click any data marker so the whole series highlights. 2: Right-click and choose Add Trendline. In Excel 2013 and later this opens the Format Trendline pane; in Excel 2007 and 2010 it opens a dialog box with the same options. 3: Under Trendline Options, pick Linear for a straight line, or Exponential, Logarithmic, Polynomial, Power, or Moving Average if the shape demands it. 4: Tick Display Equation on chart. Optionally tick Display R-squared value on chart. 5: Click the equation text box on the chart, then drag it clear of the line. You can also format it, change the font size, or move it into a cell by retyping.
Excel writes the equation with six significant digits by default. Rounding to three is usually honest for experimental data, and rounding to two decimal places hides real precision only if your measurements support it. If you need more digits, LINEST in a worksheet cell or the Analysis ToolPak's Regression tool prints the slope and intercept to fifteen significant figures.
The commonest failure is a trendline that won't appear. Add Trendline is greyed out when the chart type isn't a true scatter — a line chart with category labels on the x-axis behaves differently and may refuse the option. Convert the chart to an XY Scatter first. A second failure is a trendline that appears but produces a nonsense equation because the x values are stored as text; check with =ISNUMBER() on the x column before blaming the software.
If you want the coefficients in cells rather than on the picture, use =SLOPE(known_ys, known_xs) and =INTERCEPT(known_ys, known_xs), noting the argument order: y range first. A third function, =LINEST(known_ys, known_xs, TRUE, TRUE), spills slope, intercept, their standard errors, R², and the F statistic into a five-row block, which is what you want when you need to report uncertainty rather than just the line.
Get the Equation From a Google Sheets Chart
1: Double-click the chart to open the Chart Editor, or select it and click the three-dot menu, then Edit chart. 2: Open the Customize tab and expand the Series section. 3: Scroll to Trendline and switch it on. Choose Linear, Exponential, Polynomial, Logarithmic, Moving Average, or Polynomial with a degree from 2 to 6. 4: Below the trendline type, tick Show trendline label, then set the label type to Equation. 5: Drag the label away from the plotted points. If the label vanishes behind a data series, right-click the series and choose Bring to front on the label.
Google Sheets has a display habit worth knowing: the equation label can be cut off when the chart is small, and the fix is enlarging the chart area rather than re-adding the trendline. The label also inherits the chart's font, so a crowded chart with twelve-point labels may need the equation moved into a text box outside the plot area.
For cell-based coefficients, the functions are =SLOPE(data_y, data_x) and =INTERCEPT(data_y, data_x), same argument order as Excel. Sheets also has =RSQ(data_y, data_x) for the coefficient of determination. A useful Sheets-only trick is to lock the trendline type to "Linear" while leaving the label on; changing the type later updates both the line and the printed equation, so a stale equation can't linger.
Sheets refuses to draw a trendline at all when the x column contains text or dates stored as text. It also drops points with blank x or y values, which means the printed equation may be based on fewer rows than you think. Count the plotted markers against your data rows before you trust the coefficients.
Compute Slope and Intercept by Hand
Work through a small example to see where the numbers come from. Take five calibration points: x = 1, 2, 3, 4, 5 with y = 2.1, 3.9, 6.2, 7.8, 10.1. The x mean is 3 and the y mean is 6.02. The slope is Σ[(xᵢ − 3)(yᵢ − 6.02)] ÷ Σ(xᵢ − 3)², which works out to 20.0 ÷ 10 = 2.00. The intercept is 6.02 − 2.00 × 3 = 0.02, so the equation is y = 2.00x + 0.02.
Build the deviations in a table so the arithmetic is auditable:
| x | y | x − x̄ | y − ȳ | product | (x − x̄)² |
|---|---|---|---|---|---|
| 1 | 2.1 | −2 | −3.92 | 7.84 | 4 |
| 2 | 3.9 | −1 | −2.12 | 2.12 | 1 |
| 3 | 6.2 | 0 | 0.18 | 0 | 0 |
| 4 | 7.8 | 1 | 1.78 | 1.78 | 1 |
| 5 | 10.1 | 2 | 4.08 | 8.16 | 4 |
| Sum | — | 0 | 0.02 | 19.90 | 10 |
The sums of deviations come to zero (or near it, after rounding), which is a built-in check that the arithmetic is on track. The product column sums to 19.90 rather than exactly 20 because of rounding in the given y values; the slope is therefore 1.99, and I'd report 2.0 unless the data justify more digits. Any hand calculation whose deviation column doesn't sum to approximately zero has an error somewhere.
Be careful with the mean formula in textbooks. Some write b = (Σy − m·Σx) ÷ n, which is algebraically identical to ȳ − m·x̄ and produces the same number. If your two calculations disagree, one of the sums was transcribed wrong. A third form, b = ȳ − m·x̄, is the one to remember because it explains the geometry: the fitted line always passes through the point (x̄, ȳ).
Run the Regression in a Spreadsheet's Analysis Tools
Excel's Analysis ToolPak Regression tool prints the slope and intercept under "Coefficients" in the lower table, along with standard errors, t statistics, and confidence intervals. Enable it via File > Options > Add-ins > Excel Add-ins, tick Analysis ToolPak, and it appears under the Data tab's Analysis group. The output is a fixed block, not a live formula, so if the data change you must rerun the tool rather than recalculate.
Google Sheets has no built-in regression dialog, but =LINEST works in a spilled array. Select a two-cell-wide row, type =LINEST(B2:B10, A2:A10), and press Ctrl+Shift+Enter in older Sheets versions or plain Enter in current ones to see slope in the left cell and intercept in the right. Add the third and fourth arguments as TRUE to get the full statistics block.
A less-known route in both programs is the chart's own data-label trick: right-click a point, add a data label, and inspect its value. This is not a regression, but on a chart with a single straight series it lets you verify that the plotted coordinates match what the chart thinks the values are before you fit anything. A mismatch usually means the series is pulling from the wrong columns.
Cost and time considerations are small here but real. The Analysis ToolPak examines only the ranges you point at; a regression run on twenty thousand rows takes under a second on ordinary hardware, whereas hand check-summing that data is impractical. For large datasets, use LINEST or the tool rather than peering at a chart label, because the printed label shows six digits and the cell functions show fifteen.
Choose Linear, Polynomial, or Exponential
Line type should follow the mechanism, not the R² hunt. A linear fit suits constant-rate change, such as a dilution series or a cost per unit. An exponential fit suits growth or decay, such as radioactive counts against time or compound interest. A polynomial of degree 2 or higher can trace a curve but inflates the printed equation with terms that are hard to interpret and prone to wild behavior beyond the data range.
| Trend type | Best for | Typical degree or base | Excel label format | Main pitfall |
|---|---|---|---|---|
| Linear | Constant rate of change | m and b only | y = mx + b | Ignores curvature that is real |
| Exponential | Growth or decay | base from the data | y = a·e^(bx) or y = a·b^x | Fails when y crosses zero or goes negative |
| Logarithmic | Diminishing returns | natural log of x | y = a·ln(x) + b | Undefined for x ≤ 0 |
| Polynomial | Smooth curvature | 2 or 3 in practice | y = ax² + bx + c | Oscillates wildly outside plotted range |
| Power | Scaling laws | exponent from the data | y = a·x^b | Undefined for x ≤ 0 |
| Moving average | Smoothing noise | period in points | no single equation | Doesn't yield slope and intercept |
The rule of thumb I'd give a student: choose the simplest type that matches the physical story. Adding a cubic term raises R² almost always, but if the third-degree coefficient has no mechanistic meaning, you are fitting noise. Report the fit type alongside the equation so readers know what they are looking at.
Exponential trendlines have a specific failure mode worth naming. When any y value is negative or zero, Excel and Sheets will either drop that point or refuse the fit, because the underlying transformation is undefined. A common surprise is a dataset with one negative residual instrument reading that silently disappears from the exponential fit and leaves R² artificially high.
Validate the Line Before You Trust It
R² is a first check, not a verdict. An R² of 0.98 on twelve points suggests a good fit; an R² of 0.42 on the same points suggests a relationship worth testing, not a forecasting tool. Compute a residual for each point — actual y minus predicted y from the equation — and look for pattern. A residual plot that curves means a linear fit is missing structure; one that fans out means the variance isn't constant.
As a rough threshold, an R² of at least 0.9 is common for instrument calibration, while social-science data often settles between 0.2 and 0.6 and still supports a useful slope. The threshold is context, not law. What matters is whether the unexplained variation is small enough for your decision: if a laboratory method requires the fitted standard curve to exceed a set R², the method sheet states that number, not a textbook.
Extrapolation is the quiet danger. If your x data runs from 10 to 50 and you use the equation to predict at x = 200, you are asserting the straight line continues beyond any evidence. In calibration that can flip sign or drift in ways no linear fit anticipates. A practical guard is to restrict predictions to the observed x range and to say in the report that you did so.
Rounding deserves one paragraph of care. Excel's chart label prints six significant digits, so an equation like y = 2.00032x + 0.0187 may be reported as y = 2.00x + 0.02, and future predictions at x = 1,000 then differ by roughly 0.3 units — negligible or material depending on your tolerance. Round once, at the end, and choose digits that match your measurement precision.
Where the Trend Line Equation Goes Wrong
The first failure is the wrong chart type. A column or line chart with date labels on the horizontal axis may let you add a trendline, but the x values are treated as category positions 1, 2, 3 rather than real dates or numbers, which renders the slope meaningless. Convert to XY Scatter and the equation changes immediately; I've seen readers publish two totally different equations for the same dataset on this mistake alone.
A second failure is text-typed numbers. If x values were pasted from a web page with non-breaking spaces or from a spreadsheet exported with a leading apostrophe, the software may plot them as categories and refuse a trendline on a true scatter. Check with =ISNUMBER() on a few cells; a FALSE value means the column needs cleaning, most often via Text to Columns or a SUBSTITUTE formula that strips stray characters.
A third is the outlier that swamps the fit. One badly mismeasured point can drag the slope noticeably in a small dataset; deleting it to improve R² without reporting the deletion is data manipulation. The honest options are to keep it, check the measurement, or report the fit with and without it and say which you used. For robust regression in R, the rlm function from MASS and the lm function differ exactly on this issue.
A fourth is confusion between the trend line and a connecting line. A "line" drawn through points in plotting order joins them one by one and has no equation. A trend line is a single fitted line; if your chart shows a jagged path through the points, no amount of trendline options will conjure an equation from it. The fix is to add the trendline as a separate object on the same chart.
One more, subtler failure: an equation label that is correct at the moment it was placed but stale after the data change. Excel's chart labels don't automatically update coefficients if you replace the underlying cells — the trendline recomputes, but a typed-in equation doesn't. Retick Display Equation on chart after any data edit, or use cell formulas so the printed number is linked to live data.
FAQ
Does a high R-squared always mean the trend line is the right model?
No. An R² of 0.95 can coexist with residuals that curve systematically, because R² only measures the fraction of variance explained, not whether the line is the right shape. Check the residuals against x; a clear arc means a polynomial may fit better and a linear equation is misleading. For calibration work, inspect the deviation from a straight edge rather than relying on one number.
Why is my trendline equation different from what I calculated by hand?
Rounding is the usual culprit. Chart labels print six significant digits, and hand work often rounds intermediate sums, which shifts the final slope in the third or fourth decimal place. If the difference is larger than that, check whether the software dropped points with blank or text values; Excel and Sheets silently omit them from the fit while your hand calculation may have included the surviving values differently.
What's the difference between SLOPE() and the trendline equation?
They should agree. =SLOPE(known_ys, known_xs) gives the same slope as a linear trendline on the same data, because both use ordinary least squares. If they differ, the chart is probably referencing a different range than the function. SLOPE returns a single number and no equation label, which is why many people use both: the label for the report, the function for downstream calculations.
Can I get the equation for a trendline on a Google Sheets chart embedded elsewhere?
The trendline exists only inside the chart, so an embedded chart on a webpage or in a document carries the equation label with it but does not expose the coefficients for external use. Copy the label text into your own notes, or reproduce the fit with SLOPE and INTERCEPT in the sheet that owns the data. The chart itself is not a calculation source.
What do I do when the trendline option is greyed out?
The chart type is almost certainly wrong. A scatter plot must use numeric values on both axes; convert the chart to XY Scatter, then check that the x range is numeric with =ISNUMBER(). A related edge case is a chart with fewer than two numerical points, which has nothing to fit and disables the option until more data appears.
Is it wrong to report a trend line from fewer than five points?
It's risky. Fitting a line through two points gives a perfect line by construction and an R² that means nothing; three or four points give a slope whose uncertainty is very wide. Small calibration sets are common in teaching labs, but if the fitted curve will inform a real measurement, report the uncertainty from LINEST rather than just the equation. The number of points needed depends on the tolerance of the decision, not a fixed minimum.
How do I choose between linear and polynomial when the equation is for a report?
Pick by hypothesis, then check residuals. If the relationship is expected to be proportional (a calibration with a blank, a rate with no rate change), use linear even when a cubic improves R². Polynomial fits are easy to state and hard to defend: a degree-4 equation with four coefficients can be read as physical meaning where none exists. Document the choice and the evidence.