The Excel LINEST function performs a full least-squares linear regression and returns an array of the line's coefficients — slope(s) and intercept — optionally with a block of regression statistics such as R² and standard errors.
Syntax
| Argument | Description | |
|---|---|---|
known_ys | Required | The dependent y-values. |
known_xs | Optional | The independent x-value(s). Omit to use {1,2,3,...}. Multiple columns fit a multiple regression. |
const | Optional | TRUE (or omitted) calculates the intercept normally; FALSE forces the intercept to 0. |
stats | Optional | TRUE returns additional regression statistics (R², standard errors, F, etc.); FALSE or omitted returns only the coefficients. |
How to use it
LINEST is an array formula. For a simple one-variable fit it returns a 1×2 array: {slope, intercept} — note the coefficients come back in reverse order, slope first.
Set the fourth argument stats to TRUE and LINEST returns a larger block — the first row holds the coefficients, the second their standard errors, and lower rows hold R², the F statistic, degrees of freedom, and the regression/residual sums of squares. Supplying several columns of x-values fits a multiple linear regression in one call.
Coefficients only? If you just need one number, SLOPE and INTERCEPT return the individual values without dealing with an array. LOGEST is the exponential-curve equivalent of LINEST.
Try it: interactive demo
Pick a LINEST example to see the formula and its result.
Practice workbook
Frequently asked questions
What does LINEST return?
stats set to TRUE it returns a multi-row block adding R², standard errors, the F statistic, degrees of freedom, and sums of squares.Why is the intercept second, not first?
How do I extract just the slope from LINEST?
=INDEX(LINEST(ys,xs),1,1) for the slope and =INDEX(LINEST(ys,xs),1,2) for the intercept. Or simply use SLOPE and INTERCEPT.How is LINEST different from LOGEST?
LOGEST fits an exponential curve (y = b·m^x) and returns its coefficients. Use LINEST for linear trends, LOGEST for percentage growth.Master functions like this in one day
This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class