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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
davaru
Frequent Visitor

columns from different tables not related (n:m)

Hi Everybody.

I have 2 tables

Table A: ( date, prod_id, costs)

Table B: ( date, prod_id, incomes)

Table C: (prod_id, description)

 

Relationship TableA , TableC  cardinality Many to Ones (prod_id)

Relationship TableB , TableC  cardinality Many to Ones  (prod_id)

n:m relations between TableA & TableB

 

I need to resolve gross_margin = incomes - costs by dates

 

What must I do  ??

wich will be the DAX formulas that need ins measures o calculaed columns ???

 

Thnks in advance

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @davaru,

 

I would suggest you to use Merge Queries option in Query Editor to merge Table A and Table B into a single table(let's call it "NewMergedTable") with match columns of "date" and "prod". For more details about how to this, you can refer to this article.

 

Then you should be able to use the formula below to create a calculate column called "gross_margin" within the "NewMergedTable".

gross_margin = 'NewMergedTable'[incomes] - 'NewMergedTable'[costs]

 

Regards

View solution in original post

3 REPLIES 3
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @davaru,

 

I would suggest you to use Merge Queries option in Query Editor to merge Table A and Table B into a single table(let's call it "NewMergedTable") with match columns of "date" and "prod". For more details about how to this, you can refer to this article.

 

Then you should be able to use the formula below to create a calculate column called "gross_margin" within the "NewMergedTable".

gross_margin = 'NewMergedTable'[incomes] - 'NewMergedTable'[costs]

 

Regards

Tnks for your response.

 

 

mike_honey
Memorable Member
Memorable Member

I would add a "Calendar" table with 1 row per date, e.g. using the CALENDARAUTO function.  Then I would relate that to Table A and B. 

 

Then the Gross Margin measure would be something like this:

 

Gross Margin = SUM ( 'Table B'[incomes] )  - SUM ( 'Table A'[costs] )

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.