Correlation coefficient
Hello Daniil,
Thanks for this, this a great solution for correlation calculations on DAX.
I have tried the calculation with different measures and I will add the following improvement. In the following line, you could get a negative number.
VAR Pearson_Denominator =
SQRT ( Pearson_Denominator_X * Pearson_Denominator_Y )
I suggest this slight modification to run in all scenarios.
VAR Pearson_Denominator =
SQRT(ABS( Pearson_Denominator_X * Pearson_Denominator_Y ))
Regards,
Hi acanepa
Good programming practice would suggest avoiding a division by zero, however you need to think like a statistician - which can often be counter intuitive!
You actually want the Pearson Coefficient to "fail" when you divide by zero.
See this post for more info https://stackoverflow.com/questions/38548343/pearson-correlation-fails-for-perfectly-correlated-sets
From a DAX point of view the divide function will tolerate a division by zero.
Regards
Graeme