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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.