Forum Discussion
rampsaladi
8 years agoFrequent Visitor
Creating Co-variance using DAX
Hi Can anyone help me in getting the covariance statistics function using dax. The following is an example series. A B 1 11 2 12 3 13 4 14 5 15 6 16 7 17 8 18 ...
- 8 years ago
OK, I created a Quick Measure gallery entry here if you want to follow-up on this:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Covariance/m-p/379069#M115
Greg_Deckler
8 years agoCommunity Champion
This DAX gives me the same number that I get in Excel, 8.25 for the information given:
Covariance =
VAR AvgA = CALCULATE(AVERAGE('Covariance'[A]),ALL('Covariance'))
VAR AvgB = CALCULATE(AVERAGE('Covariance'[B]),ALL('Covariance'))
VAR MyTable = SUMMARIZE('Covariance','Covariance'[A],"Covariance",([A]-AvgA)*(MAX('Covariance'[B])-AvgB)/CALCULATE(COUNTROWS('Covariance'),ALL('Covariance')))
RETURN SUMX(MyTable,[Covariance])