Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
Calculates the linear regression of a set and returns the value of the x-intercept in the regression line, y = ax + b.
Linear regression, that uses the least-squares method, calculates the equation of a regression line (that is, the best-fit line for a series of points). The regression line has the following equation, where a is the slope and b is the intercept:
y = ax+b
The LinRegIntercept function evaluates the specified set against the first numeric expression to obtain the values for the y-axis. The function then evaluates the specified set against the second numeric expression, if specified, to obtain the values for the x-axis. If the second numeric expression is not specified, the function uses the current context of the cells in the specified set as values for the x-axis. Not specifying the the x-axis argument is frequently used with the Time dimension.
After obtaining the set of points, the LinRegIntercept function returns the intercept of the regression line (b in the previous equation).
The LinRegIntercept function ignores empty cells or cells that contain text or logical values. However, the function includes cells with values of zero.
The following example returns the intercept of a regression line for the unit sales and the store sales measures.
LinRegIntercept(LastPeriods(10),[Measures].[Unit Sales],[Measures].[Store Sales])