Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
How to calculate logarithemic regression : Y = a + b * ln (X) ?
@MFelix, @v-kelly-msft Below code is used for log regression
LogTrend-A-MB =
VAR Known =
FILTER (
SELECTCOLUMNS (
CALCULATETABLE ( VALUES ( ConsumptionDate[DateNumber] ), ALLSELECTED (ConsumptionDate) ),
"Known[X]", 'ConsumptionDate'[DateNumber],
"Known[Y]", PatientsNormalized[A-MB]
),
AND ( NOT ( ISBLANK ( Known[X] ) ), NOT ( ISBLANK ( Known[Y] ) ) )
)
VAR Count_Items =
COUNTROWS ( Known )
VAR Sum_X =
SUMX ( Known, Known[X] )
VAR Sum_X2 =
SUMX ( Known, Known[X] ^ 2 )
VAR Sum_Y =
SUMX ( Known, Known[Y] )
VAR Sum_XY =
SUMX ( Known, Known[X] * Known[Y] )
VAR Average_X =
AVERAGEX ( Known, Known[X] )
VAR Average_Y =
AVERAGEX ( Known, Known[Y] )
VAR Slope =
DIVIDE (
Count_Items * Sum_XY - Sum_X * Sum_Y,
Count_Items * Sum_X2 - Sum_X ^ 2
)
VAR Intercept = Average_Y
- Slope * Average_X
RETURN
SUMX( DISTINCT ( ConsumptionDate[DateNumber] ),
LN(Intercept + Slope * ConsumptionDate[DateNumber])
)
Hi @Anonymous ,
You can use "LOG10" function in dax expression:
Y=a+b*LOG10(X)
Here is the link for reference:
https://docs.microsoft.com/en-us/dax/log10-function-dax
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Hi @v-kelly-msft ,
I calculated using below dax but same value repeated (i.e returned same value for every row).
Log A-MB =
VAR Known =
FILTER (
SELECTCOLUMNS (
CALCULATETABLE ( VALUES ( ConsumptionDate[DateNumber] ), ALLSELECTED (ConsumptionDate) ),
"Known[X]", 'ConsumptionDate'[DateNumber],
"Known[Y]", PatientsNormalized[A-MB]
),
AND ( NOT ( ISBLANK ( Known[X] ) ), NOT ( ISBLANK ( Known[Y] ) ) )
)
VAR Count_Items =
COUNTROWS ( Known )
VAR Sum_X =
SUMX ( Known, Known[X] )
VAR Sum_X2 =
SUMX ( Known, Known[X] ^ 2 )
VAR Sum_Y =
SUMX ( Known, Known[Y] )
VAR Sum_XY =
SUMX ( Known, Known[X] * Known[Y] )
VAR Average_X =
AVERAGEX ( Known, Known[X] )
VAR Average_Y =
AVERAGEX ( Known, Known[Y] )
VAR Slope =
DIVIDE (
Count_Items * Sum_XY - Sum_X * Sum_Y,
Count_Items * Sum_X2 - Sum_X ^ 2
)
VAR Intercept = Average_Y
- Slope * Average_X
RETURN
SUMX( DISTINCT ( ConsumptionDate[DateNumber] ),
Intercept + Slope * LOG10(ConsumptionDate[DateNumber])
)
Please help me on this.
Hi @Anonymous,
What does the below expression represent for?
FILTER (
SELECTCOLUMNS (
CALCULATETABLE (
VALUES ( ConsumptionDate[DateNumber] ),
ALLSELECTED ( ConsumptionDate )
),
"Known[X]", 'ConsumptionDate'[DateNumber],
"Known[Y]", PatientsNormalized[A-MB]
)
Does there any error return?
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
That code block is used to get idividual rows of the table.
No errors code is working as expected.
REF : https://xxlbi.com/blog/simple-linear-regression-in-dax/
Hi @Anonymous ,
So your issue is solved now?
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Hi @Anonymous ,
I'm calling out to @Greg_Deckler because he has done a lot of examples for this type of situations not sure if he has done it for logotithemic.
@Greg_Deckler did you do Logarithicm on your extense DAX calculations?
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsCovering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
95 | |
80 | |
77 | |
66 |
User | Count |
---|---|
130 | |
106 | |
105 | |
86 | |
72 |