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
skean21
Regular Visitor

Calculate revenue per capita for product in contry

Dear community,

 

I would like to calculate the revenue per capita for a product in a specified country.
I tried to put this into a dax expression, without success.

 

My data structure is as follows:

Table A

CountryProduct Revenue
Country AProduct A100
Country AProduct B200
Country BProduct A50
Country BProduct C100
  

 

Table B

CountryPopulation
Country A100000
Country B200000
Country C50000
 

 

Table A and Table B are linked in both ways on the column "Country"

 

I have tried this DAX expression without success, for every product I get the same value.

Revenue_per_capita =
    sum('Table A'[Revenue])/
sum('Table B'[Population])
 
Thanks for your help.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @skean21  please create this measure in tableA.

 

Measure = 
VAR _country = MAX(TableA[Country])
VAR _population = CALCULATE(SUM(TableB[Population]),TableB[Country]=_country)
VAR _revenue = SUM(TableA[Revenue])
RETURN DIVIDE(_revenue,_population,0)

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @skean21  please create this measure in tableA.

 

Measure = 
VAR _country = MAX(TableA[Country])
VAR _population = CALCULATE(SUM(TableB[Population]),TableB[Country]=_country)
VAR _revenue = SUM(TableA[Revenue])
RETURN DIVIDE(_revenue,_population,0)

 

 

Spoiler
thanks a lot, that works!

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.

Top Solution Authors