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
Anonymous
Not applicable

New column to calculate profit value

Hi, Is it possible to add a new column that calculates the value using the relationships between the 3 tables?

Actually, I want to calculate the total profit of each country, of a real estate company that have branches in many countries and each branch, has many properties

Table 1: Country Id, Country Name

Table 2: Country Id, Property Id

Table3: Property Id, Profit

The difficulty is that there are several properties in each country, which means several values represent the profits in each country. so the query should sum all these profit values for each country.

you can see the actual tables in this link: https://prntscr.com/118mfhb

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

To show the result clearly, have modified your sample data. Based on your description, DAX and power query both could achieve this.

1. You can use DAX formula to create a calculated column directly:

TotalProfit =
CALCULATE (
    SUM ( Profit[TotalProfit] ),
    'Country'[CountryID] IN DISTINCT ( 'Property'[CountryID] ),
    'Property'[PropertyID] IN DISTINCT ( 'Profit'[PropertyID] )
)

r2.png

 

2. You can also use the 'Merge' feature in power query to merge table twice to get the same result:

m1.pngm2.pngr1.png

 

Best Regards,
Community Support Team _ Yingjie Li
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

3 REPLIES 3
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

To show the result clearly, have modified your sample data. Based on your description, DAX and power query both could achieve this.

1. You can use DAX formula to create a calculated column directly:

TotalProfit =
CALCULATE (
    SUM ( Profit[TotalProfit] ),
    'Country'[CountryID] IN DISTINCT ( 'Property'[CountryID] ),
    'Property'[PropertyID] IN DISTINCT ( 'Profit'[PropertyID] )
)

r2.png

 

2. You can also use the 'Merge' feature in power query to merge table twice to get the same result:

m1.pngm2.pngr1.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you so much for this clear answer

sayaliredij
Super User
Super User

I think this problem is easily addressed if you just import this table in power bi and make the relationship between them.

You can create a measure 

Profit = SUM(Profit)

In this way, you can have profit available on each level . You just need to drag and drop columns

In case you want to create new table out of it

 

CountryWise = SUMMERIZECOLUMNS( CountryName, "Profit", SUM(Profit))

 

Regards,

Sayali 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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
Top Kudoed Authors