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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors