
📎 This article includes 1 downloadable practice file ↓
In this article
LINEST fits a straight line (or a multiple regression) and returns slope, intercept and, optionally, R², standard errors and more — an entire regression output from one formula.
Syntax
=LINEST(known_ys, [known_xs], [const], [stats])
| Argument | What it means |
|---|---|
known_xs |
One or more columns of predictors. |
stats |
TRUE for the full statistics block. |
Examples
Example 1
=LINEST(D2:D40, B2:C40, TRUE, TRUE)
Sales explained by ad spend and price: spills a 5-row stats table.
Example 2
=INDEX(LINEST(D2:D40, B2:B40), 1)
Just the slope.
LINEST in practice
Where you will use it
- Slope and intercept in one go
- Multiple regression
- Trend statistics
Worked example
| Output | Formula | Result |
|---|---|---|
| Slope | =ROUND(INDEX(LINEST({100,108,115,124,130,139},{1,2,3,4,5,6},TRUE,TRUE),IF(ROW()=4,3,1),IF(ROW()=3,2,1)),4) | 7.7143 |
| Intercept | =ROUND(INDEX(LINEST({100,108,115,124,130,139},{1,2,3,4,5,6},TRUE,TRUE),IF(ROW()=4,3,1),IF(ROW()=3,2,1)),4) | 92.3333 |
| R² | =ROUND(INDEX(LINEST({100,108,115,124,130,139},{1,2,3,4,5,6},TRUE,TRUE),IF(ROW()=4,3,1),IF(ROW()=3,2,1)),4) | 0.9982 |
Results calculated in Excel.
Mistakes people make
| Mistake | What to do instead |
|---|---|
| Array output | LINEST returns a table; use INDEX to pick values |
| Order of results | Coefficients come in reverse order of x columns |
Related functions
📚 Part of the free Excel course: Beginner → Expert · Try it in the Formula Lab or ask the AI Helper.
Test formulas dynamically in our web formula laboratory or download the companion Excel workbook.
📎 Practice files for this article
- 📗Practice workbook: Statistics advanced33 tasks on realistic sales data — type your formula, the Check column turns green when it is right. Answers sheet included.⬇ XLSX · 36 KB
Free to use for learning. Files with macros (.bas) are plain text — import them with Alt+F11 → File → Import File, and always test on a copy.
Atul (AJ) builds office-automation and local-first AI tools as Atulya AI, and works with Excel, SAP and Oracle EPM every day. He writes about the shortcuts, macros and automations that actually save time — plus the occasional wacky fact. Videos on YouTube: Lazy Automator AI (@LazyAutomatorAI).
More posts by Atul →Build this skill next
This page is a quick function reference. Use it for syntax, then practise the function in a broader workflow.
Stuck on a step? Ask a question and the AI answers using this article.