LINEST Function
Returns regression statistics (slope, intercept, and more) as an array.
Syntax
Parameters
| Parameter | Description | Required |
|---|---|---|
| known_ys | The dependent (y) values of the known data. | Required |
| known_xs | The independent (x) values; for multiple regression supply several columns. Defaults to 1,2,3,... if omitted. | Optional |
| const | TRUE (or omitted) includes an intercept; FALSE forces the line through the origin. | Optional |
| stats | FALSE (or omitted) returns just slope and intercept; TRUE adds standard errors, R-squared, F, df, and sums of squares. | Optional |
Basic Example
Get slope and intercept of a fitted line
=LINEST({2,3,5,7,11},{1,2,3,4,5})The fitted line is y = -1 + 2.2x, so LINEST returns slope 2.2 and intercept -1 (entered as an array in two cells).
Advanced Examples
Example 1: Full regression statistics
Need diagnostics, not just the lineSet stats to TRUE for a 2-row by 5-column array
=LINEST({2,3,5,7,11},{1,2,3,4,5},TRUE,TRUE)Example 2: Multiple regression
Two independent variablesPass two columns as known_xs
=LINEST(C2:C20,A2:B20,TRUE,TRUE)How LINEST Works
LINEST performs ordinary least-squares regression, minimizing the sum of squared residuals. With a single x it fits y = a + bx and returns the slope and intercept (and, with stats=TRUE, the full diagnostic block). With multiple x-columns it returns one slope per column plus the intercept. Because it is an array function, the results spill into adjacent cells.
Important Notes & Limitations
Returns an array, so in pre-dynamic Excel it must be entered as an array formula with enough empty cells to spill into.
known_xs and known_ys must have the same number of rows, or #REF! is returned.
If the x-columns are linearly dependent, the function returns #REF! because the regression cannot be solved.
Common Errors & Fixes
#REF!Array sizes mismatch or the x-columns are collinear (linearly dependent).Fix: Match row counts and remove redundant/duplicate x-columns.
Wrong values spillOutput range too small or not entered as an array.Fix: Select a large enough range and use Ctrl+Shift+Enter (legacy Excel).
Download Practice File
LINEST
linestPractice LINEST with Real Data
Download a sample CSV file with pre-populated data and practice exercises for the LINEST function. Works in both Excel and Google Sheets.
File format: CSV (comma-separated values) - opens in Excel, Google Sheets, and all spreadsheet apps