To find the slope in an Excel graph, add a linear trendline and display its equation, or calculate the slope directly with Excel’s SLOPE function. The trendline method shows the result on the chart; the formula method gives you a precise value in a worksheet cell. Before starting, arrange your data in paired x- and y-values so each x-value matches the y-value from the same observation.
What You’ll Need
- Excel for Microsoft 365 on Windows. The steps below use its desktop ribbon; Excel for Mac has similar chart options, while some chart controls may be arranged differently in Excel for the web.
- At least two pairs of numeric values: one column for the independent variable (x) and one for the measured value (y). More observations usually make a trendline slope more informative.
- A scatter chart if the x-values are numeric measurements or are not evenly spaced. A line chart may be appropriate for equally spaced categories, but its horizontal axis does not always represent the actual numeric distances between x-values.
Step-by-Step
- Arrange the data in two columns. Put x-values in the first column and corresponding y-values in the second, with a clear heading in each column. For example, enter x-values 1, 2, 3, and 4 in A2:A5, and y-values 3, 5, 7, and 9 in B2:B5. Each row is one paired observation; do not sort one column without sorting the other.
- Select both columns, including their headings. Highlight A1:B5 in the example. If the columns are separated, select the x-values first and then hold Ctrl while selecting the y-values on Windows. Keeping x and y next to each other is simpler and reduces the chance of assigning the wrong series.
- Insert a scatter chart. Choose Insert > Insert Scatter (X, Y) or Bubble Chart > Scatter. Select the basic scatter option with markers. Excel should use the first selected column as x-values and the second as y-values. Check the chart before continuing: the horizontal axis should show the x-values, and the plotted points should match your data.
- Add a linear trendline. Click a data point once to select the data series. On the ribbon, choose Chart Design > Add Chart Element > Trendline > Linear. In some Excel layouts, you can instead use the chart’s plus icon and select Trendline, then use its arrow to choose Linear. A linear trendline fits a straight line to the plotted points; it does not simply connect each point in sequence.
- Show the trendline equation. Right-click the trendline and choose Format Trendline. In the Format Trendline pane, select Display Equation on chart. Excel adds an equation in the form y = mx + b. The coefficient multiplying x, shown as m, is the slope. In the example, the equation is y = 2x + 1, so the slope is 2.
- Read the slope with its units. A slope of 2 means y increases by 2 units, on average according to the fitted line, for each 1-unit increase in x. If x is time in days and y is distance in metres, the slope is 2 metres per day. The slope is not just a visual steepness: the axis scales and units matter.
- Increase the equation’s displayed precision if needed. Excel may round the equation shown on the chart. To change the displayed digits, right-click the equation label, choose Format Trendline Label, and use the Number options in the formatting pane to set additional decimal places. For an exact worksheet value, use the SLOPE function rather than copying a rounded chart label.
- Calculate the slope directly in a cell. With x-values in A2:A5 and y-values in B2:B5, enter
=SLOPE(B2:B5,A2:A5)in an empty cell. The first argument is the known y-values and the second is the known x-values. For the example data, the result is 2. This is the least-squares slope for the same set of paired observations used by a linear trendline. - Check that the chart and formula use the same data. Compare the chart’s selected series ranges with the cell ranges in the formula. If you have blank rows, filtered records, or extra values, verify which observations are included. The displayed equation and SLOPE result should agree apart from rounding when both use the same numeric pairs and a linear fit.
Common Mistakes
Using the wrong chart type: A line chart treats horizontal positions as categories, which can make irregularly spaced numbers appear evenly spaced. For example, x-values 1, 2, and 10 are not separated by equal intervals. Use an XY scatter chart when the actual numeric gaps between x-values matter.
Reversing the SLOPE arguments: Excel’s order is known_y’s first, known_x’s second. Swapping them calculates a different relationship, not the intended change in y for a change in x.
Mixing up paired values: Each x-value must remain beside its corresponding y-value. Sorting one column alone, including a heading in only one range, or selecting the wrong series can produce a misleading result.
Assuming the line passes through every point: A linear trendline minimizes the overall squared vertical differences between the points and the line. It generally does not connect each point, and the slope describes the fitted relationship rather than every step from one observation to the next.
Ignoring units or rounding: A slope has units of y per unit of x, and a displayed chart equation may be rounded. Note the measurement units and use the formula result if you need more precision.
Tips
- Give both axes clear titles with units. This makes a slope such as 0.45 easier to interpret as, for example, 0.45 centimetres per second rather than as a bare number.
- Keep x and y data numeric. Values stored as text, labels mixed into the data range, and cells containing errors can prevent Excel from plotting or calculating the intended pairs.
- Use a meaningful x-axis scale. If your x-values are dates, an XY scatter chart plots their numeric date spacing; the slope is then in y-units per day. Format the axis labels as dates if that makes the chart easier to read.
- Show the R-squared value on the chart only if it helps explain the fit. In the Format Trendline pane, select Display R-squared value on chart. R-squared describes how closely the fitted line accounts for variation in the plotted y-values; it is not the slope and does not prove that one variable causes another.
- For a quick check between two observations, calculate the change in y divided by the change in x. With the first two example observations in A2:B3, enter
=(B3-B2)/(A3-A2)in an empty cell; the result is 2. This is the slope between those two points, which can differ from the trendline slope when you use more than two observations. - Keep the data ranges easy to audit. If you add new rows regularly, convert the data to an Excel table using Insert > Table, then confirm that the chart series expands as expected when you add records.
Troubleshooting
The chart has no trendline option: Confirm that you selected the plotted data series, not the chart title or an axis. Also check that the chart is an eligible chart type, such as an XY scatter chart. Select a point in the series and try Chart Design > Add Chart Element > Trendline > Linear again.
The equation does not appear: Select the trendline itself, open Format Trendline, and enable Display Equation on chart. If you selected the data series instead, the pane may show series formatting options rather than trendline options. You can move the equation label by dragging it so it does not cover the points.
The slope seems implausible: Check that the x- and y-ranges have the same number of observations and correspond row by row. Confirm that the horizontal axis is using the intended x-values, that the numbers are not stored as text, and that there are no unintended extra points. Then compare the chart with =SLOPE(B2:B5,A2:A5), assuming x is in A2:A5 and y is in B2:B5.
The equation shows too few decimals: Format the trendline label’s number display to show more decimal places, or use SLOPE in a cell. The chart label is for presentation and can round the coefficient; it may not expose every digit in the calculated result.
The line looks wrong for curved data: A linear trendline may be a poor fit if the points follow a curve or if a few extreme values strongly affect the fit. Inspect the scatter plot and consider whether a straight-line summary is suitable before interpreting its slope. Do not change trendline type merely to make the chart look more convincing.
The controls differ on Mac or the web: In Excel for Mac, select the chart and use the Chart Design tab to add a trendline; the Format Trendline pane provides the equation option. Excel for the web may have fewer chart-formatting controls depending on the current interface. If you cannot display the equation there, open the workbook in Excel for Microsoft 365 desktop or calculate the value with SLOPE, which is also available in Excel for the web.
Frequently Asked Questions
What does slope mean on an Excel graph?
The slope is the change in the vertical value for each one-unit change in the horizontal value. In the equation y = mx + b, m is the slope and b is the y-intercept.
How do I find the slope without adding a trendline?
Use SLOPE in a worksheet cell. If x-values are in A2:A5 and y-values are in B2:B5, enter =SLOPE(B2:B5,A2:A5). The function returns the fitted linear slope for those paired values.
Why is the slope different from the change between two points?
A slope calculated from two points describes just those points. A trendline or SLOPE calculation with several observations finds a least-squares line across the full set, so its slope may differ from the slope between any particular pair.
Can I find slope from a line chart?
You can add a trendline to many line charts, but the horizontal axis may represent evenly spaced categories rather than numeric distances. Use an XY scatter chart if the x-values are measurements, dates with meaningful spacing, or otherwise unevenly spaced numbers.
Does a steeper-looking line always have a larger slope?
Not necessarily. The visual angle depends on the chart’s horizontal and vertical scales. Compare the numerical slope and its units rather than judging steepness by appearance alone.
What if Excel gives a #DIV/0! error?
Check that the x-values contain enough usable numeric observations and are not all identical. If the x-values have no variation, Excel cannot calculate a line slope because the horizontal change is zero.
Related
- How to Enable the Text Import Wizard in Excel for CSV Files
- How to Enable Track Changes in Excel
- Enable Scroll Lock in Excel: Keyboard and On-Screen Methods
Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.
More in Charts & pivot tables
- Excel Sparklines: Can You Use Multiple Data Ranges?In Excel, each sparkline shows one sequence of values in one cell; it does not combine several separate…
- How to Edit an Org Chart in Excel: Steps and FixesTo edit an org chart in Excel, click a box and change its text, or select the chart…
- 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…
- Excel Histogram Bin Range: Set or Change BinsTo set an Excel histogram’s bins in Microsoft 365 for Windows, select the chart’s horizontal axis, choose Format…
- How to Make a Waterfall Chart in ExcelTo make a waterfall chart in Excel, arrange your categories and positive or negative changes in two columns,…
- COUNTA in Google Sheets Pivot Tables ExplainedIn a Google Sheets pivot table, COUNTA counts how many non-empty values appear in a selected field for…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.