Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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 |
9 | 19 |
10 | 20 |
Based on the Covariance formula I did an individual average subtracted from the values and mutipled them and divided by the toal N. The problem I see that when i do the Average of the series and use that average to subtract from each value of the series the values I get are different from the values I get when i do the same thing in Excel. Any help in this regard is appreciated
Solved! Go to Solution.
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
@rampsaladi - One question, where did you get that formula for covariance, because it is not necessarily jiving with what I am seeing here:
https://en.wikipedia.org/wiki/Covariance
https://math.tutorvista.com/statistics/covariance.html
@Greg_Deckler Thanks for looking it up quickly, I know there is a Covariance function in Power Query but was not sure how to use it as I have never used the M and as far as the formula is concerend I got it from the below site.
http://mathworld.wolfram.com/Covariance.html
I do have the expected value for the co-variance so I will use the DAX that you provided and see how it matches up
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
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])
There is a List.Covariance function in Power Query. I will look into this for DAX, do you have what the result should be for the information provided?
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
61 | |
61 | |
55 | |
38 | |
27 |
User | Count |
---|---|
83 | |
61 | |
45 | |
41 | |
39 |