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
Nexans
Frequent Visitor

Many-to-many relationships on World Bank data

Hi. 

 

I'm just starting to learn Power BI and is struggeling to gasp some basic consepts. I have connected to various data sources from world bank through their API, and is now trying to create some calculated colums. 

 

My first task was to calculate GDP per capita by dividing GDP with population from the population table. Problem I am facing is that this is not possible. I think my problem is the data model, but I am not able to figure this one out.

 

Can somebody please assist? See the attached file.

 

Download Power BI file

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

Hi @Nexans

Steps as below:

1.Create calculated columns in the "GDP, Current USD" table

population =
CALCULATE (
    SUM ( 'Population, total'[Population] ),
    FILTER (
        ALL ( 'Population, total' ),
        'Population, total'[CountryID] = EARLIER ( 'GDP, Current USD'[CountryID] )
            && 'Population, total'[Year] = EARLIER ( 'GDP, Current USD'[Year] )
    )
)

2.Create measure in the same table

GDP = SUM('GDP, Current USD'[GDP USD ($)])
DIVIDE = DIVIDE([GDP],MAX('GDP, Current USD'[population]),0)

1.png

In the table, there is a row with blank row in “country” column, but with values in “DIVIDE” measure,

This is because there are some “country id“ exist in the” GDP, Current USD” and “Population, total” table, but not exist in the “Countries” table.

 

Best Regards

Maggie

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Nexans

Steps as below:

1.Create calculated columns in the "GDP, Current USD" table

population =
CALCULATE (
    SUM ( 'Population, total'[Population] ),
    FILTER (
        ALL ( 'Population, total' ),
        'Population, total'[CountryID] = EARLIER ( 'GDP, Current USD'[CountryID] )
            && 'Population, total'[Year] = EARLIER ( 'GDP, Current USD'[Year] )
    )
)

2.Create measure in the same table

GDP = SUM('GDP, Current USD'[GDP USD ($)])
DIVIDE = DIVIDE([GDP],MAX('GDP, Current USD'[population]),0)

1.png

In the table, there is a row with blank row in “country” column, but with values in “DIVIDE” measure,

This is because there are some “country id“ exist in the” GDP, Current USD” and “Population, total” table, but not exist in the “Countries” table.

 

Best Regards

Maggie

v-juanli-msft
Community Support
Community Support

Hi @Nexans

Since your pbix contains some real data, I would send you a private message including the modified pbix.

Please check if you receive it.

 

Best Regards

Maggie

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.