In Excel, a linear trendline is described by y = mx + b: m is the slope and b is the y-intercept. To show its equation, select the chart, choose Chart Design > Add Chart Element > Trendline > More Trendline Options, then select Display Equation on chart in the Format Trendline pane.
What an Excel trendline equation tells you
A trendline is a mathematical model fitted to the data in a chart series. Its equation summarizes the relationship Excel estimates between the horizontal values (x) and vertical values (y). For a linear trendline, the slope indicates how much the predicted y value changes when x increases by one unit; the intercept is the predicted y value at x = 0.
For example, if the equation is y = 2x + 1, the model predicts that y rises by 2 for each one-unit increase in x. At x = 4, it predicts y = 9. The equation describes the fitted trend, not necessarily a rule that every observed data point follows. Real observations may sit above or below the line.
Excel’s chart equation uses x and y as placeholders. It does not automatically show your worksheet cell references, and it does not create a formula in a cell. If you need predictions in cells, calculate the model’s coefficients separately or use a forecasting function.
How to display the equation in Excel
These steps apply to Excel for Microsoft 365 on Windows. Use an XY (Scatter) chart when your x-values are numeric measurements, such as dates represented as numbers, time, distance, or temperature. A line chart treats its horizontal axis as categories, which may not be appropriate when the spacing between x-values matters.
- Select the chart, or create an XY (Scatter) chart from paired x- and y-value columns.
- Choose Chart Design > Add Chart Element > Trendline, then pick a model such as Linear. To adjust model options, choose More Trendline Options.
- In the Format Trendline pane, choose the desired trendline type. Select Display Equation on chart to show its equation. You can also select Display R-squared value on chart.
- Move or format the equation label so it does not cover data. To show more digits, right-click the equation label, choose Format Trendline Label, and adjust its number format.
Another route in desktop Excel is to select the chart and click the Chart Elements button (the plus sign beside the chart), point to Trendline, and choose More Options. Excel for Mac has similar chart design and trendline controls, although the pane layout and location of commands can differ by release. Excel for the web has fewer chart-editing controls than the desktop app; if the equation option is unavailable, open the workbook in desktop Excel.
Common trendline equation types
The model should match the shape and meaning of the data, not simply produce an equation that looks familiar. Excel offers several trendline types for chart series:
- Linear: y = mx + b. Use it when the relationship is reasonably well represented by a straight line over the range being analyzed.
- Exponential: y = aebx. This models a rate of change that is proportional to the current value, often producing a curved increase or decrease. Excel requires positive y-values for an exponential trendline.
- Logarithmic: y = a ln(x) + b. This can fit a pattern that changes quickly at first and then levels off. Its x-values must be positive.
- Power: y = axb. This is useful for some scale relationships, such as a quantity changing as a power of another positive quantity. The x- and y-values must be positive.
- Polynomial: y = bnxn + … + b1x + b0. Choose an order to allow curvature; higher orders can follow fluctuations in the sample rather than a stable underlying pattern.
- Moving average: This smooths short-term variation across a chosen number of points. It does not provide a single trendline equation in the same way as the other listed models.
Excel may display coefficients rounded to a limited number of decimal places. The chart line is calculated from its underlying coefficients, so typing the displayed, rounded equation into a worksheet can produce slightly different predictions. Increase the label’s displayed precision if needed, but for accurate calculations it is usually better to calculate coefficients in cells.
Calculate a linear trendline in worksheet cells
Suppose the x-values are in A2:A6 and the y-values are in B2:B6, with paired data (1, 3), (2, 5), (3, 7), (4, 9), and (5, 11). The points fall exactly on y = 2x + 1. Excel’s SLOPE and INTERCEPT functions return the coefficients for the least-squares linear fit.
With x-values in A2:A6 and y-values in B2:B6, enter this formula to calculate the slope; it returns 2:
=SLOPE(B2:B6,A2:A6)
With the same layout, enter this formula to calculate the intercept; it returns 1:
=INTERCEPT(B2:B6,A2:A6)
Together, those results give the fitted equation y = 2x + 1. To predict the y-value for x = 6, use FORECAST.LINEAR. With x-values in A2:A6, y-values in B2:B6, and the target x-value 6 entered in D2, the formula returns 13:
=FORECAST.LINEAR(D2,B2:B6,A2:A6)
These functions use paired numeric values and estimate the ordinary least-squares straight line. If there are blanks, text values, or mismatched ranges, check the data before interpreting the results. For the example, the equation predicts 13 at x = 6 even though 6 is outside the observed x-range; that is an extrapolation, and its reliability depends on whether the same pattern continues beyond the measured data.
Read R-squared without overinterpreting it
R-squared, often written R², indicates how closely a fitted model accounts for variation in the observed y-values under the model’s calculation. In the example above, all points lie exactly on the line, so R² is 1. A value nearer 1 can indicate a closer fit to the data, but it does not prove that the model is correct, that x causes y, or that future observations will follow the same pattern.
With x-values in A2:A6 and y-values in B2:B6, this formula calculates the linear fit’s R-squared; for the exact example data, it returns 1:
=RSQ(B2:B6,A2:A6)
R² values should be compared cautiously across different model types and data ranges. A flexible, high-order polynomial can fit existing points closely while behaving poorly between or beyond them. Consider the chart, the data collection process, residual patterns, and the purpose of the model as well as the displayed statistic.
Choosing a model and checking the chart
Start with the shape of the data and a reason for choosing a particular relationship. A straight-line model is a useful first check for a roughly consistent increase or decrease. Exponential or power models may suit different curved patterns, but they have data restrictions and imply different behaviors. A polynomial may represent bends in the observed range, but a higher order is not automatically better.
Before relying on an equation, check these points:
- Confirm that each x-value is paired with the correct y-value and that both ranges cover the same observations.
- Use a scatter chart for numeric x-values when spacing and numeric distances matter.
- Inspect the data for outliers or separate groups that may distort a single fitted line.
- Check whether the model’s assumptions and value restrictions make sense for the data.
- Be cautious about extrapolating beyond the measured x-range, especially for curved models.
Why the equation may look wrong
A surprising slope or intercept can result from the chart’s data selection, rather than a calculation error. Select the chart and use Chart Design > Select Data to inspect the series. For an XY (Scatter) chart, check that the intended cells are assigned as the series’ X values and Y values. If x-values were omitted or treated as categories, the plotted relationship may not represent the intended measurements.
Other common causes include rounded equation labels, a trendline type that does not suit the data, and missing or nonnumeric values. A very small slope may also be hidden by the label’s rounding. Increase the number of displayed decimal places and compare the equation with coefficients calculated in worksheet cells. If Excel will not create an exponential, logarithmic, or power trendline, check the model’s positive-value requirements.
Frequently Asked Questions
Where is the trendline equation in Excel?
Select the chart, add a trendline through Chart Design > Add Chart Element > Trendline > More Trendline Options, then select Display Equation on chart in the Format Trendline pane.
What do m and b mean in a linear trendline?
In y = mx + b, m is the slope and b is the y-intercept. The slope is the predicted change in y for a one-unit increase in x; the intercept is the model’s predicted y when x equals zero.
How do I use the trendline equation in a cell?
Calculate the slope and intercept with SLOPE and INTERCEPT, then use those coefficients in a cell formula or use FORECAST.LINEAR for a prediction. This avoids relying on coefficients rounded in the chart label.
Why does my chart equation differ from my worksheet result?
The displayed equation may round its coefficients, and the chart series may use different x- or y-values than your worksheet calculation. Check the series ranges and increase the equation label’s decimal precision before comparing results.
Does a high R-squared mean the trendline is accurate?
Not by itself. It describes fit to the data used, not causation or guaranteed predictive accuracy. Consider the pattern, model choice, data quality, and whether a prediction is inside the measured range.
Practical takeaway
For the standard linear trendline, Excel’s equation is y = mx + b, and the chart can display it through the Format Trendline pane. Treat that label as a readable summary: verify the chart’s data ranges, understand the model type, and calculate coefficients in worksheet cells when you need precise predictions.
Related
- Excel: Specify Which Duplicate to Remove?
- Excel Solver With Binary Options: Setup and Examples
- Excel Solver With Integer Values: Setup and Examples
Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.
More in Charts & pivot tables
- Excel Histogram With a Line Chart: How to Build OneYes. In Excel for Microsoft 365 on Windows, the most dependable way to put a line on a…
- Find a Pivot Table in Excel: Locate It Across SheetsTo find an existing PivotTable in Excel, search the workbook for a label or value you know appears…
- How to Make a Flow Chart in Word Online: Step by StepTo make a flow chart in Word Online, open a document, choose Insert > Shapes, draw and label…
- Butterfly Graph in Excel: How to Build and Format OneTo make a butterfly graph in Excel, put one comparison series in negative values and the other in…
- Excel: How to Turn On Power Pivot and Build Data ModelsTo turn on Power Pivot in Excel for Microsoft 365 on Windows, select File > Options > Add-ins.…
- Excel Pivot Tables: How to Create and Use ThemTo create a PivotTable in Excel for Microsoft 365 on Windows, select a cell in your data, choose…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.