Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Calculates the linear regression of a set and returns the coefficient of determination, R2.
LinRegR2(Set_Expression, Numeric_Expression_y [ ,Numeric_Expression_x ] )
Set_Expression
A valid Multidimensional Expressions (MDX) expression that returns a set.
Numeric_Expression_y
A valid numeric expression that is typically a Multidimensional Expressions (MDX) expression of cell coordinates that return a number that represents values for the y-axis.
Numeric_Expression_x
A valid numeric expression that is typically a Multidimensional Expressions (MDX) expression of cell coordinates that return a number that represents values for the x-axis.
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 LinRegR2 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 the values for the x-axis. Not specifying the x-axis argument is frequently used with the Time dimension.
After obtaining the set of points, the LinRegR2 function returns the statistical R2 that describes the fit of the linear equation to the points.
Note
The LinRegR2 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 statistical R2 that describes the goodness of fit of the linear regression equation to the points for the unit sales and the store sales measures.
LinRegR2(LastPeriods(10), [Measures].[Unit Sales],[Measures].[Store Sales])
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today