1. Home
  2. Functions
  3. Statistical
  4. LINEST

LINEST function

Fits a straight line (or a plane for several x columns) by least squares and returns its coefficients and optional statistics.

Syntax

=LINEST(known_ys, [known_xs], [const], [stats])

Arguments

ArgumentRequiredDescription
known_ysRequiredThe dependent values
known_xsOptionalThe independent values, one column per variable (1, 2, 3... when left out)
constOptionalTRUE or left out to calculate the intercept, FALSE to force it to 0
statsOptionalTRUE to also return the regression statistics

How to use LINEST

When LINEST returns more than one value, the result spills into the cells below and to the right. Keep those cells empty, or you get #SPILL!.

LINEST takes 1 required argument and 3 optional arguments. Type =LINEST( in a cell and SheetsBat shows the arguments as you go. Optional arguments are shown in square brackets; leave them out to use their default.

Examples

Each result below was calculated by the SheetsBat formula engine.

=LINEST({1;9;5;7}, {0;4;2;3})Result 1 by 2 array
Spilled result
AB
121
=LINEST({3;5;7}, {1;2;3}, FALSE)Result 1 by 2 array
Spilled result
AB
12.4285714290

Every formula, right in your browser

SheetsBat calculates 536 functions, with charts, pivot tables and live collaboration. Free to start.