The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I reviewed an number of posts and videos on how to do linear regression.
I can get a regression of "vbat vs ts" to work when i create a new TABLE using the following;
Regression = LINESTX('LowPower', [vbat], [ts])
And then create a new MEASURE "vbat_lr" using;
vbat_lr =
var _m = SELECTCOLUMNS(Regression, [Slope1])
var _b = SELECTCOLUMNS(Regression, [Intercept])
var x = SELECTEDVALUE(LowPower[ts])
var y = _b + _m * x
RETURN y
However, other tutorials suggest not using a regression table and embedding the LINESTX function in the MEASURE;
vbat_lr =
var _reg = LINESTX('LowPower', [vbat], [ts])
var _m = SELECTCOLUMNS(_reg, [Slope1])
var _b = SELECTCOLUMNS(_reg, [Intercept])
var x = SELECTEDVALUE(LowPower[ts])
var y = _b + _m * x
RETURN y
This doesnt work!
My vbat_lr measure gives identical values to vbat (suggesting that _lr has Slope1=1 and Intercept=0)
I would prefer not having an extra table and getting the second method working.
I very new to PowerBI.
Hopefully somebody can see what I am doing wrong with embedding the LINESTX in the measure.
SELECTCOLUMNS will produce a list. You normally need to convert that into a scalar value. In your case the table produced by LINESTX is already a single row table, so your approach may work.
Do you have some sample data points from the LowPower table?
User | Count |
---|---|
80 | |
78 | |
37 | |
34 | |
31 |
User | Count |
---|---|
93 | |
81 | |
60 | |
49 | |
49 |