LINEST Function

Excel Functions › Statistical

All versions Statistical

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.


Quick answer:
=LINEST(B2:B7, A2:A7) returns {slope, intercept} for y vs x

Syntax

=LINEST(known_ys, [known_xs], [const], [stats])
ArgumentDescription
known_ysRequiredThe dependent y-values.
known_xsOptionalThe independent x-value(s). Omit to use {1,2,3,...}. Multiple columns fit a multiple regression.
constOptionalTRUE (or omitted) calculates the intercept normally; FALSE forces the intercept to 0.
statsOptionalTRUE 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.

=LINEST(B2:B7, A2:A7) // {slope, intercept}
=INDEX(LINEST(B2:B7,A2:A7),1,1) // pull just the slope

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

Live demo

Pick a LINEST example to see the formula and its result.

Result:

Practice workbook

📊
Download the free LINEST practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

Frequently asked questions

What does LINEST return?
An array. For a single-variable fit the default is a 1×2 array {slope, intercept}. With 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?
LINEST returns coefficients in reverse order of the x-variables, ending with the intercept. For one x that gives {slope, intercept}; for several x's the slopes appear right-to-left, then the intercept last.
How do I extract just the slope from LINEST?
Wrap it in INDEX: =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?
LINEST fits a straight line (y = mx + b); 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

Related functions: LOGEST · TREND · SLOPE · INTERCEPT · RSQ