Forum Discussion
smpa01
Community Champion
3 years agoLINEST forEach
AlexisOlson bcdobbs CNENFRNL
I am trying to crerate a measure using LINEST that would give me the slope but I have not been successful.
PFA what I have tried.
Following is what I d...
- 3 years ago
Hi smpa01 ,
Please try:
Measure = var _a = FILTER(ALL('fact'),'fact'[Country]=MAX('fact'[Country])) return MAXX(CALCULATETABLE(LINEST('fact'[y],'fact'[x]),_a),[Slope1])Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 3 years ago
smpa01 You could create a measure that returns a text table using TOCSV and parse that.
For example:
LINEST Output = VAR _filteredTable_ = FILTER ( ALL ( 'fact' ), 'fact'[Country] = MAX ( 'fact'[Country] ) ) VAR _linEst_ = LINESTX ( _filteredTable_, 'fact'[y], 'fact'[x] ) VAR _toText = TOCSV ( _linEst_, , "|", FALSE() ) RETURN _toTextThen you can define the following:
Slope1 = PATHITEM ( [LINEST Output], 1 )ResidualSumOfSquares = PATHITEM ( [LINEST Output], 10 )
v-jianboli-msft
Community Support
3 years agoHi smpa01 ,
Please try:
Measure =
var _a = FILTER(ALL('fact'),'fact'[Country]=MAX('fact'[Country]))
return MAXX(CALCULATETABLE(LINEST('fact'[y],'fact'[x]),_a),[Slope1])
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.