Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

How to calculated logirothemic regression manually using DAX?

How to calculate logarithemic regression : Y = a + b * ln (X)  ?

@MFelix 

8 REPLIES 8
Anonymous
Not applicable

@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])
)
v-kelly-msft
Community Support
Community Support

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!

Anonymous
Not applicable

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!

Anonymous
Not applicable

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!

Anonymous
Not applicable

No @v-kelly-msft still waiting..

MFelix
Super User
Super User

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


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.