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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Dynamic Pearson Correlation Coefficient

I am attempting to build a dashboard which would allow a user to see how similar their skill level is to a list of other occupations based on estimated skill levels from previous occupations they have worked. Essentially how it would work is a user can select occupations from a filter that they have worked in the past and the highest score for each skill would be collected and used in the correlation coefficient score to compare to the other occupations. The dataset looks like this: 

OccupationSkillScore
Chief Executives and Managing DirectorsReading8
Chief Executives and Managing DirectorsLearning8
Chief Executives and Managing DirectorsProblem solving8
Chief Executives and Managing DirectorsOral communication8
Chief Executives and Managing DirectorsPlanning and organising9
Chief Executives and Managing DirectorsInitiative and innovation9
Chief Executives and Managing DirectorsNumeracy6
Chief Executives and Managing DirectorsDigital engagement6
Chief Executives and Managing DirectorsTeamwork7
Chief Executives and Managing DirectorsWriting7
General ManagersPlanning and organising8
General ManagersInitiative and innovation8
General ManagersNumeracy5
General ManagersDigital engagement6
General ManagersTeamwork7
General ManagersWriting7
General ManagersReading7
General ManagersLearning6
General ManagersProblem solving6
General ManagersOral communication7
Livestock FarmersPlanning and organising9
Livestock FarmersInitiative and innovation8
Livestock FarmersNumeracy6
Livestock FarmersDigital engagement4
Livestock FarmersTeamwork5
Livestock FarmersWriting6
Livestock FarmersReading6
Livestock FarmersLearning6
Livestock FarmersProblem solving6

Livestock Farmers

Oral communication6

 

So for example if a user selected a Livestock farmer using the filter which has a writing score of 6 and a chief executive officer which has a writing score of 7 then the writing score would be 7 and would be the one used in the correlation calculation. Once the calculation is done I am trying to have a table of all occupations with the correlation coefficient scores showing how similar the users skills are to that occupation, something like this: 

OccupationCorrelation Coefficient
Payroll Clerk0.706156854
Purchasing Officer0.702705206
Contract Administrator0.690257461
Corporate Services Manager0.687506663
Management Accountant0.669461421
Financial Investment Manager0.664373231


I've been trying to use the following measure but nothing is being displayed in my table: 

 

 

 

 

 

CorrelationCoefficient = 
VAR SelectedOccupation = SELECTEDVALUE('SelectedOccupations'[Occupation])
VAR SelectedOccupationScores =
    VALUES('Core competencies'[Score])
VAR AllOccupations = VALUES('Core competencies'[Occupation])

RETURN
CALCULATE(
    AVERAGEX(
        FILTER(AllOccupations, NOT 'Core competencies'[Occupation] = SelectedOccupation),
        DIVIDE(
            SUMX(
                INTERSECT(
                    VALUES('Core competencies'[Skill]),
                    VALUES('Core competencies'[Skill])
                ),
                CALCULATE(
                    SUMX(
                        FILTER('Core competencies', 'Core competencies'[Occupation] = SelectedOccupation),
                        'Core competencies'[Score]
                    ) *
                    CALCULATE(
                        SUMX(
                            FILTER('Core competencies', 'Core competencies'[Occupation] = 'Core competencies'[Occupation]),
                            'Core competencies'[Score]
                        )
                    )
                )
            ),
            SQRT(
                SUMX(
                    SelectedOccupationScores,
                    'Core competencies'[Score]^2
                ) *
                SUMX(
                    VALUES('Core competencies'[Skill]),
                    CALCULATE(
                        SUMX(
                            FILTER('Core competencies', 'Core competencies'[Occupation] = VALUES('Core competencies'[Occupation])),
                            'Core competencies'[Score]^2
                        )
                    )
                )
            )
        )
    ),
    ALL('Core competencies'[Occupation])
)

 

 

 

 

 

 

Does anyone know how I can modify this measure so that I can get a visualisation similar to the example I provided? Apologies for my ignorance on this topic, I am fairly new to DAX. 

 

Thank you in advance for any help.

1 REPLY 1
lbendlin
Super User
Super User

There are numerous articles on that topic

power bi pearson correlation at DuckDuckGo

 

There is even a Quick Measure that implements a (slightly quirky) version.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.