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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Schwami
New Member

Correlation Factor on Bar Chart

I have the following simplified table. 

Schwami_0-1681829897261.png

 

I can put this on a scatter plot to show some correlation. 

Schwami_1-1681829954653.png


And I can create a correlation measure (quick measure or not). And that all works fine. 

Schwami_2-1681830015302.png


Where I'm running intoo issues is the following. I would like to plot this correlation coefficient onto a bar chart with my department category, but that doesn't seem to be working. 

Schwami_3-1681830091222.png

 



What am I overlooking here? 

Can anybody assist. 




1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Schwami 

According to your description and dax code , the _mX and _mY  also return the current Label Department's value, so after the calculation it also return 0 .

var _mX = CALCULATE( AVERAGE('Test 2'[Number of Employees]))
var _mY = CALCULATE( AVERAGE('Test 2'[Number of Employees left]))
 
You can try to use this dax code to get the total average of the current Label Department.

Correlation Coefficient =
var _mX = CALCULATE( AVERAGE('Test 2'[Number of Employees]),ALL('Test 2'[Label Department]))
var _mY = CALCULATE( AVERAGE('Test 2'[Number of Employees left]),ALL('Test 2'[Label Department]))
var _Num = SUMX('Test 2',('Test 2'[Number of Employees]-_mX)* ([Number of Employees left]-_mY))
var _test =SUMX('Test 2',([Number of Employees] - _mX)^2)*SUMX('Test 2',([Number of Employees left]-_mY)^2)
var _Den =SQRT(
SUMX('Test 2',([Number of Employees] - _mX)^2)*SUMX('Test 2',([Number of Employees left]-_mY)^2))
return
DIVIDE(_Num,_Den)

 

You can also put this measure on the Table visual and update the return value to test , like this:
return
_Num

 

So you can find which parameter return the wrong value in your measure.

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi , @Schwami 

According to your description and dax code , the _mX and _mY  also return the current Label Department's value, so after the calculation it also return 0 .

var _mX = CALCULATE( AVERAGE('Test 2'[Number of Employees]))
var _mY = CALCULATE( AVERAGE('Test 2'[Number of Employees left]))
 
You can try to use this dax code to get the total average of the current Label Department.

Correlation Coefficient =
var _mX = CALCULATE( AVERAGE('Test 2'[Number of Employees]),ALL('Test 2'[Label Department]))
var _mY = CALCULATE( AVERAGE('Test 2'[Number of Employees left]),ALL('Test 2'[Label Department]))
var _Num = SUMX('Test 2',('Test 2'[Number of Employees]-_mX)* ([Number of Employees left]-_mY))
var _test =SUMX('Test 2',([Number of Employees] - _mX)^2)*SUMX('Test 2',([Number of Employees left]-_mY)^2)
var _Den =SQRT(
SUMX('Test 2',([Number of Employees] - _mX)^2)*SUMX('Test 2',([Number of Employees left]-_mY)^2))
return
DIVIDE(_Num,_Den)

 

You can also put this measure on the Table visual and update the return value to test , like this:
return
_Num

 

So you can find which parameter return the wrong value in your measure.

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors