To find a trendline’s gradient in Excel, calculate its slope with SLOPE or display the equation on a chart and read the coefficient of x. With x-values in A2:A6 and y-values in B2:B6, enter =SLOPE(B2:B6,A2:A6) in an empty cell; for the example below, the result is 3. The gradient tells you how much y changes, on average, for each one-unit increase in x.
Excel often calls the gradient the slope. This guide shows both the direct calculation and the chart method, so you can get a precise value or see the trendline equation alongside your data.
What You’ll Need
- A worksheet containing paired numeric x-values and y-values. Each x-value must correspond to the y-value on the same row.
- Excel for Microsoft 365 on Windows for the ribbon instructions below. Excel for Mac has similar chart options, though labels and layout can vary. The SLOPE formula also works in Excel for the web.
- For the chart method, an XY (Scatter) chart is recommended because it treats the x-values as numbers rather than category labels.
Step-by-Step
- Arrange and check the data. Put the independent variable, or x-values, in one column and the measured outcome, or y-values, in the next. Keep each pair on the same row and include a clear header if you like. For example, enter x-values 1, 2, 3, 4, 5 in A2:A6 and y-values 5, 8, 11, 14, 17 in B2:B6. Check that the cells contain numbers, not numbers stored as text, and remove any accidental headings from the selected ranges. A gradient only makes sense when each x-value is paired with its corresponding y-value.
- Calculate the gradient directly. With x-values in A2:A6 and y-values in B2:B6, select an unused cell and enter
=SLOPE(B2:B6,A2:A6). Press Enter. The first argument is the known y-values; the second is the known x-values. For the example data, the result is 3: y increases by 3 whenever x increases by 1. This is the simplest method when you need a number to use in another calculation or report. SLOPE calculates the slope of the best-fit linear regression through the selected pairs, rather than simply subtracting the first y-value from the last. - Select the data for a chart. Highlight A1:B6, including the headers if you added them. If the columns are not next to each other, select the x-range and then the y-range using the usual selection method for your operating system. Verify that x-values are assigned to the horizontal axis and y-values to the vertical axis; if Excel assigns them incorrectly, use Chart Design > Select Data to edit the series. Getting this assignment right matters: reversing x and y changes the slope.
- Insert an XY scatter chart. Choose Insert > Insert Scatter (X, Y) or Bubble Chart, then select a scatter option with markers. A scatter chart plots the actual numeric x-values, which is the appropriate basis for this kind of trendline. A standard Line chart may treat horizontal-axis entries as evenly spaced categories, even when the labels look numeric. The chart is useful for seeing the overall pattern, but the trendline is what provides the fitted linear relationship.
- Add a linear trendline. Click a data marker in the chart so that the data series is selected. Choose Chart Design > Add Chart Element > Trendline > More Trendline Options. In the Format Trendline pane, select Linear if it is not already selected. The line shows the best-fit straight-line pattern for the plotted points; it does not have to pass through every point. If the data curves noticeably, a linear trendline may not describe it well, so consider whether a different model is appropriate before interpreting one constant gradient.
- Show the trendline equation. In the Format Trendline pane, select Display Equation on chart. Excel places an equation on the chart, usually in the form y = mx + b. The coefficient multiplying x, m, is the gradient. For the example values, the fitted equation is y = 3x + 2, so the gradient is 3 and the intercept is 2. Do not confuse the intercept, the value after the plus or minus sign, with the gradient.
- Read enough decimal places. The equation label can round its coefficients, which may make its displayed gradient look slightly different from the SLOPE result. To show more digits, select or right-click the equation label, open Format Trendline Label, and adjust the Number format and decimal places. Keep the SLOPE result as the more precise value when precision matters. If the equation label is hard to read, move it to an open area of the chart or enlarge the chart before recording the coefficient.
- Check the meaning and units. Describe the result as y-units per x-unit. If x measures hours and y measures distance in kilometres, a gradient of 3 means an estimated increase of 3 kilometres per hour. A positive gradient means the fitted y-value rises as x increases; a negative gradient means it falls; a gradient close to zero indicates little linear change. State the units and the range of data used when you share the result.
Common Mistakes
Putting the ranges in the wrong order: SLOPE takes y-values first and x-values second. If you reverse the arguments, you calculate a different relationship. The chart’s equation also depends on the series being assigned correctly, so check both axes.
Using a Line chart for numeric x-values: A Line chart can space categories evenly rather than use the actual distances between x-values. For example, x-values 1, 2, and 10 should not be plotted as if the final gap were the same as the first. Use an XY Scatter chart when x is a measured number.
Reading the wrong part of the equation: In y = mx + b, the gradient is m, the number attached to x. The constant b is the y-intercept. The equation might instead show a negative intercept or a minus sign; that does not change which coefficient is the gradient.
Assuming the trendline must touch every point: A regression line balances the distances between the points and the fitted line. It generally will not pass through all observations. Also, a straight-line gradient summarizes a linear trend; it is not a constant rate for data that follows a curve.
Trusting a rounded label as an exact answer: A chart may display only a few decimal places. Do not copy a rounded coefficient when you need a precise result; calculate it with SLOPE and format the result cell for the desired number of decimals.
Tips
Use clear column headers, such as Time (hours) and Distance (km), so the chart and your explanation preserve the measurement units. If you need the gradient in a presentation, show the equation on the chart and also state the gradient in a nearby text box or caption. Readers should not have to infer whether the coefficient is measured per hour, per day, or per some other unit.
Keep the chart’s equation and the calculation cell linked to the same data ranges. If you add new observations, update the chart series and the SLOPE ranges; otherwise, the equation and formula may describe different sets of points. An Excel Table can help keep related data together, but check that any chart or formula includes the new rows after the table grows.
For a quick visual check, compare the sign and approximate steepness of the line with the SLOPE result. A line that rises from left to right should have a positive gradient, and one that falls should have a negative gradient. This check can reveal swapped axes or a mistaken range, but it is not a substitute for checking the cell references.
If the chart is being prepared for a report, include the data range, units, and whether the line is linear. Avoid implying that the trendline proves one variable causes the other. It describes an association in the supplied data, and using it to predict values far outside that data range can be unreliable.
Troubleshooting
The formula returns #DIV/0!: Check that the x-range contains at least two usable numeric values and that the x-values are not all identical. A slope cannot be calculated if there is no variation in x. Also confirm that the x and y ranges contain the same number of cells.
The result is unexpectedly zero or wrong: Confirm that the ranges point to the intended columns and that the arguments are in y-then-x order. Check for numbers stored as text, blank cells, or stray values included at the edge of a range. If a copied formula shifted its references, select the result cell and inspect the formula bar.
The displayed equation differs from SLOPE: First increase the equation label’s displayed decimal places. Then confirm the chart series uses the same observations as the formula and that the x and y columns have not been swapped. Small differences caused by label rounding are normal; differences that remain after these checks usually point to mismatched data or chart assignments.
The trendline option is missing or greyed out: Select the chart and then click a plotted data series, not the chart title or plot background. Confirm that the chart type supports a trendline, such as XY Scatter. In Excel for Mac, look for the chart design and format controls after selecting the chart; ribbon names or pane placement can differ slightly. In Excel for the web, use SLOPE if the chart controls available in your browser do not offer the equation-label option.
The line looks unlike the data: Verify the x-axis values and chart type, then consider whether a straight-line model fits the pattern. A curved relationship can make a linear gradient misleading. You can inspect other trendline options in the Format Trendline pane, but do not report the coefficient as a constant rate unless the chosen model and its interpretation support that conclusion.
Frequently Asked Questions
Is gradient the same as slope in Excel?
Yes. In this context, gradient and slope mean the coefficient that describes the change in y for a one-unit change in x. Excel’s worksheet function is named SLOPE.
Which number in the trendline equation is the gradient?
In y = mx + b, the gradient is m, the coefficient attached to x. The other number, b, is the y-intercept. For example, in y = 3x + 2, the gradient is 3.
Can I get a trendline gradient without making a chart?
Yes. Use SLOPE with the y-values as the first argument and the x-values as the second. This returns the fitted linear gradient directly in a worksheet cell.
Why does SLOPE give a different value from the first-to-last change?
SLOPE uses all selected data pairs to calculate the best-fit linear regression. Dividing the change between only the first and last points uses just two observations, so it can differ when the other points do not fall exactly on that line.
Can a trendline have a negative gradient?
Yes. A negative gradient means the fitted y-value decreases as x increases. Check that the axes are assigned correctly before interpreting the sign.
Does a curved trendline have one gradient?
Not usually. A curved model can have a changing slope at different x-values, so it does not have one constant gradient across the whole range. SLOPE returns a single linear summary, not the local slope of a curve.
Related
- Roundup Excel Without Decimals: 10 Reliable Methods
- Excel MODE.MULT: Find Multiple Modes in a Data Set
- Excel Days, Hours, and Minutes: Format Durations
Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.
More in Charts & pivot tables
- Excel Pie Chart: How to Change the Order of SlicesTo change the order of slices in an Excel pie chart, reorder the category and value rows in…
- Excel Bar Chart Different Color Bars: How to Set ThemYes. In Excel for Microsoft 365 on Windows, select the chart, right-click a bar, choose Format Data Series,…
- How to Create a Timer Chart in ExcelCreate a countdown timer chart in Excel by putting the duration, elapsed time, and remaining time in worksheet…
- Google Sheets Chart Data Range: Set, Edit, and Fix ItIn Google Sheets, a chart’s data range is the cell range that supplies its labels and values. To…
- Pivot Table Value Filter Not Working? Fix the CauseA PivotTable value filter usually seems broken because it is filtering a different summary than you expect, the…
- Excel Dashboard Software Examples: Tools, Uses, and LimitsExamples of software used to create dashboards from Excel data include Microsoft Excel, Microsoft Power BI, Tableau, Qlik…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.