How to Calculate a Chart Trendline's Slope and Intercept in Excel
Question details
The user wants to calculate the slope and intercept of a linear chart trendline directly in spreadsheet cells so the values update dynamically when source data changes.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Performing data analysis with linear charts and needing to use the trendline equation components in other worksheet calculations automatically.
- Observed behavior
- Instead of manually copying the static equation displayed on a chart, the goal is to use built-in formulas that automatically recalculate the slope and intercept when data points are modified.
Ensure your chart's source data is organized into two separate columns or rows—one containing the independent X values and the other containing the dependent Y values.
Calculate Slope and Intercept Using Built-in Functions
Use Excel's SLOPE and INTERCEPT functions to calculate the trendline values directly from your source data, allowing for automatic updates.
Instead of extracting values from the chart's visual equation, referencing the source data directly via statistical functions ensures your numbers remain accurate and dynamic.
Select an empty cell where you want the slope to appear. Type =SLOPE(known_y's, known_x's), replacing the arguments with your actual data ranges (e.g., =SLOPE(B2:B10, A2:A10)), and press Enter.
Select another empty cell for the intercept value. Type =INTERCEPT(known_y's, known_x's) using the exact same data ranges (e.g., =INTERCEPT(B2:B10, A2:A10)), and press Enter.

Get Slope and Intercept Simultaneously Using LINEST
Use the LINEST array function to output both the slope and the y-intercept into adjacent cells at the same time.
Calculate Trendlines and Analyze Data Seamlessly in WPS Spreadsheet
WPS Spreadsheet fully supports advanced statistical functions like SLOPE, INTERCEPT, and LINEST. You can effortlessly analyze chart trendlines and manipulate data exactly as you would in other major spreadsheet software.
- 1. Open your data file: Launch WPS Spreadsheet and open the workbook containing your X and Y dataset.
- 2. Calculate the slope: Select a blank cell and enter the formula =SLOPE(Y_range, X_range).
- 3. Calculate the intercept: In an adjacent cell, enter =INTERCEPT(Y_range, X_range) to retrieve the Y-intercept.
- 4. Visualize the trendline: Go to the Insert tab, create a Scatter chart from your data, and add a Linear Trendline to visually verify your calculated results.

Frequently Asked Questions
Why do my formula results differ from the equation shown on the chart?
This usually happens if your chart is a Line chart instead of a Scatter (X Y) chart. Line charts treat X-axis values as equally spaced categorical labels (1, 2, 3...) regardless of their actual numeric value. Ensure you are using a Scatter chart so the visual trendline matches the mathematical calculations.
Do SLOPE and INTERCEPT functions ignore blank cells?
Yes, both the SLOPE and INTERCEPT functions are designed to appropriately handle empty data points. They will automatically ignore blank cells and cells containing text within the specified data ranges.
Can I calculate the R-squared value directly in a cell as well?
Yes, you can calculate the R-squared (coefficient of determination) value without extracting it from the chart by using the =RSQ(known_y's, known_x's) function in any blank cell.




