Excel Trendline Equation: How to Get It From Data in Excel

Charts & pivot tables · Updated November 21, 2026

To get an Excel trendline equation from data, make a chart, select its data series, and add a trendline. In Excel for Microsoft 365 on Windows, choose Chart Design > Add Chart Element > Trendline > More Trendline Options, then select Display Equation on chart in the Format Trendline pane. The equation describes the fitted pattern; the steps below explain how to choose a useful model and check what the result means.

What a trendline equation tells you

A trendline is a mathematical model fitted to the points in a chart. Its equation summarizes how the vertical values, usually called y, relate to the horizontal values, usually called x. For a linear trendline, the general form is y = mx + b: m is the slope, and b is the value the line would have at x = 0. For example, a slope of 2 means the model predicts that y increases by 2 units for each one-unit increase in x.

The equation is an estimate based on the data you supplied, not a rule that guarantees future results. It is useful for describing an approximate relationship, making calculations within a relevant range, or communicating a trend. It does not establish that changes in x caused changes in y, and predictions far beyond the observed data can be unreliable.

Add a trendline and show its equation

  1. Arrange the data in two columns: x values in one column and corresponding y values in the next. Include clear headings, but do not include totals or blank rows in the plotted range.
  2. Select the two columns and choose Insert > Insert Scatter (X, Y) or Bubble Chart > Scatter. Pick a scatter chart with markers if you want Excel to use the actual numerical x values.
  3. Select a point in the data series. Right-click and choose Add Trendline. Alternatively, select the chart and use Chart Design > Add Chart Element > Trendline > More Trendline Options.
  4. In the Format Trendline pane, choose the model that fits the question, such as Linear. Scroll to the options near the bottom and select Display Equation on chart. You can also select Display R-squared value on chart.
  5. Move or resize the equation label if it covers data. To show more digits, select the label, open Format Trendline Label, and adjust its number format and decimal places.

In Excel for Mac, the chart ribbon and trendline formatting pane provide equivalent controls, though their position and wording can vary slightly by release. If the chart is selected, look for the Chart Design tab and its Add Chart Element menu; selecting More Trendline Options opens the formatting controls. The Windows directions above apply to Microsoft 365 on Windows.

Choose the right chart and model

The chart type matters because it determines how Excel interprets the horizontal axis. An XY scatter chart treats x as numerical values, so a gap from 2 to 4 is twice a gap from 2 to 3. A line chart generally uses a category axis, where each plotted category occupies one position. If x values are measurements such as time, distance, or temperature, a scatter chart is usually the safer choice for fitting a relationship against the actual numbers.

Excel offers several trendline types. Choose based on the shape and meaning of the data, rather than selecting a model just because it produces a high R-squared value:

  • Linear: A straight-line relationship, useful when the change in y is roughly constant for each unit of x.
  • Exponential: A curve that changes by a roughly constant proportion rather than a constant amount. Excel requires positive y values for this trendline.
  • Logarithmic: A curve that changes quickly at first and then levels off. It requires positive x values.
  • Power: A relationship where y varies with a power of x. Both x and y must be positive.
  • Polynomial: A curved model that can bend more than once. Excel lets you set its order, from 2 through 6; a higher order can fit the sample closely but may behave erratically outside it.
  • Moving average: A smoothed sequence that helps reveal local direction in an ordered series. It is not a single equation in the same sense as the other models, so Excel does not provide a standard trendline equation label for it.

For chronological observations, make sure the dates are genuinely ordered and consider whether the data should be evenly spaced. A scatter chart uses date serial values as x coordinates; a line chart spaces categories evenly. If missing dates or unequal intervals matter, the distinction can change what the visual trend represents.

Read the equation and R-squared carefully

Suppose Excel displays y = 2x + 1. The model predicts y by multiplying x by 2 and adding 1. At x = 5, it predicts 11. The slope has units of y per unit of x, while the intercept has the same units as y. An intercept can be mathematically necessary even when x = 0 is outside the observed range; in that case, it may not have a useful real-world interpretation.

R-squared, often written R², summarizes how much of the variation in the plotted y values is accounted for by the fitted model in the context of that regression. A value closer to 1 indicates a closer fit to the sample under the model being used. It is not a measure of causation, proof that the model is appropriate, or a guarantee of predictive accuracy. A high-order polynomial can achieve a high R² by following the particular points closely while making poor predictions for new data.

Excel rounds the equation displayed on the chart. The rounded label may not reproduce every plotted value exactly if you copy its coefficients into another calculation. Increase the label’s displayed decimal places when precision matters, and, for calculations, obtain coefficients directly from worksheet functions or a regression analysis rather than relying on rounded chart text.

Worked example with a linear trendline

Imagine the x values 1, 2, 3, and 4 correspond to y values 3, 5, 7, and 9. Put the x values in A2:A5 and the y values in B2:B5, with headings in row 1. A scatter chart with a linear trendline should show an equation close to y = 2x + 1, with an R² of 1. Each step of one in x is associated with an increase of two in y, and all four points fall exactly on the line.

With x values in A2:A5 and y values in B2:B5, calculate the slope using =SLOPE(B2:B5,A2:A5), which returns 2. With the same layout, calculate the intercept using =INTERCEPT(B2:B5,A2:A5), which returns 1. These results match the displayed model. For example, when x is 5, the prediction is 11.

With the x value to predict entered in A6 and the slope and intercept stored in C2 and C3, respectively, calculate the predicted y in B6 using =$C$2*A6+$C$3. If A6 contains 5, the formula returns 11. The dollar signs keep the coefficient references fixed if you copy the prediction formula down a column, while A6 changes to A7, A8, and so on.

Get coefficients without reading the chart label

For a straight-line model, SLOPE and INTERCEPT return the fitted coefficients directly. This is useful when a report or later calculation needs full numeric precision, or when you want to create a prediction column. Keep the input ranges aligned: each x value must correspond to the y value on the same row, and both ranges should contain the same number of observations.

For more detailed regression output, the Analysis ToolPak offers Regression under Data > Data Analysis. If Data Analysis is not visible, enable the Analysis ToolPak through File > Options > Add-ins, select Excel Add-ins in the Manage box, choose Go, and check Analysis ToolPak. The ToolPak can provide regression statistics and residual output, which can help assess a linear model beyond the chart’s equation and R². It is an add-in feature rather than a requirement for displaying a trendline.

For polynomial or other non-linear chart trendlines, do not assume SLOPE and INTERCEPT reproduce the chart’s model: those functions calculate a straight-line fit. The chart can display the equation for supported trendline types, but creating a reliable worksheet calculation for a different model may require fitting its coefficients separately. Check the chosen method and the model’s assumptions before using the result for decisions.

Common problems and ways to check the result

  • The equation option is missing: Confirm that a data series is selected and that the Format Trendline pane is open. A trendline label is added through the trendline options, not the chart title or axis formatting.
  • The chart looks right but the equation seems wrong: Check that you used an XY scatter chart when x represents numeric measurements. Also verify that x and y values have not been swapped and that the plotted series excludes headings, totals, or unintended rows.
  • The model will not accept the data: Exponential, logarithmic, and power models have domain restrictions. Check for zero or negative values, and use a different model if the data do not meet the selected type’s requirements.
  • The displayed coefficients give slightly different predictions: Increase the number of decimals on the equation label. Excel may display rounded coefficients even though the chart’s fitted line uses more precision.
  • The equation fits the visible points but predicts badly: Inspect the data pattern, outliers, and residuals, and avoid extrapolating without justification. A visually smooth curve or large R² does not by itself validate the model.
  • The trendline does not follow the expected dates: Check whether a line chart is treating dates as evenly spaced categories. Use a scatter chart if actual numeric spacing between dates is important.

A useful check is to plot observed values against predictions or examine residuals, which are observed y values minus predicted y values. If residuals show a curve or another systematic pattern, a straight line may be missing structure in the data. If one point has unusual influence, verify that it is an authentic observation before deciding whether it belongs in the analysis; removing it simply to improve the fit can distort the conclusion.

Frequently Asked Questions

How do I show the trendline equation in Excel?
Select the chart series, add a trendline, and open More Trendline Options. In the Format Trendline pane, check Display Equation on chart. Add Display R-squared value on chart as well if you want that fit statistic shown.

How do I calculate the trendline equation from cells?
For a linear trendline, use SLOPE for the coefficient of x and INTERCEPT for the constant term. Put the x and y ranges in corresponding rows and use the same ranges for both functions. These functions do not calculate polynomial or exponential trendline equations.

Why does Excel show a different equation than my calculator?
The chart label may round its displayed coefficients, and the software or chart type may use different assumptions about the x values. Check the number format on the label, use a scatter chart for numeric x values, and compare like-for-like models and data ranges.

Can I use the equation to predict values?
Yes, an equation can calculate model-based estimates, but predictions are strongest within a range supported by the observed data. Treat extrapolations beyond that range cautiously, and do not interpret a fitted relationship as evidence that one variable causes another.

What does R-squared mean on an Excel trendline?
R² describes how closely the fitted model accounts for variation in the sample data under that model. It can help compare fits in context, but it does not prove that the model is appropriate, establish causality, or guarantee accurate predictions for future observations.

Related

Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.

More in Charts & pivot tables

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.