Forum Discussion
Trend analysis using linear regression gradient per category
- Anonymous2 years ago
Hi PowerBIUserX
I add a month column in the table
Then modifiy the Lines measure
Lines = VAR a = LINESTX ( FILTER ( ALLSELECTED ( 'Table' ), [Category] IN VALUES ( 'Table'[Category] ) ), [Value_measure], [Month] ) RETURN MINX ( a, [Slope1] )Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi Anonymous ,
Thank you for your reply. While it works on the limited dataset I initially provided, I do not think the solution works in all cases.
If I understand correctly, the measures you suggested calculate the slope [ (y2-y1)/(x2-x1) ] of the maximum point and minimum point in the dataset, but not the slope of the regression. In the dataset it works because they are already linear functions.
On the following dataset (non-linear function), the slope I am expected is -3.5%, but your measure returns -45%.
Do you have an idea on how to achieve the same but with the slope of the linear regression?
Hi PowerBIUserX
I add a month column in the table
Then modifiy the Lines measure
Lines =
VAR a =
LINESTX (
FILTER ( ALLSELECTED ( 'Table' ), [Category] IN VALUES ( 'Table'[Category] ) ),
[Value_measure],
[Month]
)
RETURN
MINX ( a, [Slope1] )
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- PowerBIUserX2 years agoFrequent Visitor
Works perfectly! Thank you so much 😊