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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
red_ltxj
Frequent Visitor

Dynamically Calculating Correlation Coefficients Based on Selections of Field Parameters

Hi everyone,

I would like to create a function where I can dynamically calculate correlation coefficients between two indexes of countries (e.g., Cost of Living Index, Groceries Index, etc.) based on selections on two separate Fields Parameter Slicers, with the fields of those parameters as the different indexes. There are five indexes in total. I basically want this to be visualized in conjunction with a scatterplot with the X and Y axes dynamically updating based on selections on that same Fields Parameter Slicer.

I understand that there will probably be a lot of DAX involved, but is anyone able to help point me in the right direction on what to do? I've attached a screenshot of the page I'd like to achieve this on (I intend to have the dynamically calculated coefficients on the left side, with the field parameters along the X and Y axes of the scatterplot determining which indexes to calculate coefficients for. Thanks!

This is the dataset in case that's helpful: https://www.kaggle.com/datasets/myrios/cost-of-living-index-by-country-by-number-2024

red_ltxj_0-1726073580732.png

 

3 REPLIES 3
mo_measures
New Member

I feel like there is probably a better way but maybe this will help spur some ides.... Create two new tables

 

X_Table ={"Cost of Living","Groceries","Purchasing Power" ...}

Y_Table = {"Cost of Living","Groceries","Purchasing Power" ...}

then use switch

 

X_Switch = SWITCH(SELECTEDVALUE(X_Table),

"Cost of Living",SUM(Cost of Living)

"Grocersies",SUM(Groceries)

etc

Y_Switch = SWITCH(SELECTEDVALUE(X_Table),

"Cost of Living",SUM(Cost of Living)

"Grocersies",SUM(Groceries)

etc

 

Then use the X Switch and Y Switch in the corrleation formula. and add slicers to page with X table, Y table.

red_ltxj
Frequent Visitor

Hi @Anonymous 

I need the scatter chart to change dynamically according to what is selected on the two Field Parameters along the X and Y axis of the scatter chart, which I've managed to figure out on my own. The parameters are based on columns. 

However, I would like to dyanmically calculate correlation coefficients based on what is selected on those same two Field Parameters. I've attached sample data below. Thanks!

RankCountryCost of Living IndexRent IndexCost of Living Plus Rent IndexGroceries IndexRestaurant Price Index
Local Purchasing Power Index
1Switzerland101.146.574.9109.197158.7
2Bahamas8536.761.881.683.354.6
3Iceland8339.26288.486.8120.3
4Singapore76.767.272.174.650.4111.1
5Barbados76.61948.980.869.443.5
6Norway7626.252.17973.5114.7
7Denmark72.326.450.264.881.3127.2
8Hong Kong (China)70.859.465.384.646.2109.3
9United States70.441.756.67567.2142.3
10Australia70.233.452.577.362.5127.4
11Austria65.122.544.766.459.3102.4
12Canada64.833.249.671.261.7103.7
13New Zealand64.625.94671.957.1121
14Ireland64.442.353.859.365.3101.1
15France63.72143.269.556.3102.4
16Puerto Rico63.319.542.364.153.1103.5
17Finland63.219.742.46363.6118
18Netherlands63.133.548.959.961.2124.9
19Israel62.727.145.659.66899.4
20Luxembourg62.440.551.964.168.7182.5
21Germany62.224.44460.852.8120.2
22United Kingdom6231.147.156.962.7115.2
23Belgium61.120.141.457.566109.8
24South Korea60.11638.981.431.4109.4
25Sweden59.320.940.960.854.7122.6
26Italy56.219.238.55753.378.3
27United Arab Emirates55.841.348.945.349.2127.9



Anonymous
Not applicable

Hi @red_ltxj 

 

Due to some security policies, I cannot open your link. Could you please provide sample data in the form of screenshots?

 

In addition, I would like to confirm your requirements with you. Do you need the scatter chart to change dynamically according to the parameter you selected? Is your parameter columns or measures?

 

Best Regards,
Yulia Xu

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.