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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
bourne2000
Helper V
Helper V

How to sum related to Many to Many relationship

Hi

 

I have two tables,

 

Table 1:

 

ProductIDPaid Amount
A10
B20
C30
D40
E50
F60
G70
H80

 

 

Table 2:

 

ProductIDTotalDue
A30
B40
C50
D60
K70
L80
M30
N40
I50
O60
  

 

Both Table 1 & Table 2 has connected with Product ID and it is Many to Many Relationships

 

What I need?

 

1) Wanted to calculate Remaining Amount for the productID presented in Table 1

 

I used below dax

 

Remaining Amount = sum(Table2[Total Due]) - sum(Table1[Paid Amount]) 

 

However it is not working

 

Expected Output

 

ProductIDPaid AmountTotal DueRemaning Amount
A103020
B204020
C305020
D406020

 

2) Wanted to print the Table 1 records which is not presented in the Table 2

 

Expected Output

 

ProductIDPaid Amount
E50
F60
G70
H80

 

I don't want to use any bridge table, possible to solve through DAX?

 

Kindly advise

 

1 ACCEPTED SOLUTION
SamInogic
Solution Sage
Solution Sage

Hi,

 

As per our understandings you are looking for DAX formulae to get required data and have Many many to relationship in your tables, so have created sample data as per your requirement as follows:

 

Table 1

 Table1.png
Table 2
Table2.png

Relationship Between table will be as Following 

Relationship.png
You can create a new column [Total Due] by using below DAX Expression 

 

Total Due = LOOKUPVALUE('Table 2'[TotalDue],'Table 2'[ProductID],'Table

 1'[ProductID])

 

Then create a new column for Remaining Amount using below DAX expression,

Remaining Amount = IF('Table 1'[Total Due]-'Table 1'[Paid Amount]>=0,'Table

 1'[Total Due]-'Table 1'[Paid Amount],0)

Output.png

Regarding second question to find non-matching records from table 2 you can create new column in Table 1 with below DAX expressions:

ExistInTable2 = IF(ISBLANK(LOOKUPVALUE('Table 2'[ProductID],'Table 2'[ProductID], 'Table 1'[ProductID])), "No","Yes")

 

And to display only records which are not present in Table 2 you can apply filter on the table visual as ExistInTable as “No”.

Please refer to the below screenshot for the same,

second output.png

If this answer helps, please mark it as Accepted Solution so it would help others to find the solution.


Thanks!

Inogic Professional Service Division

An expert technical extension for your techno-functional business needs

Power Platform/Dynamics 365 CRM

Drop an email at crm@inogic.com

Service:  http://www.inogic.com/services/ 

Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

View solution in original post

1 REPLY 1
SamInogic
Solution Sage
Solution Sage

Hi,

 

As per our understandings you are looking for DAX formulae to get required data and have Many many to relationship in your tables, so have created sample data as per your requirement as follows:

 

Table 1

 Table1.png
Table 2
Table2.png

Relationship Between table will be as Following 

Relationship.png
You can create a new column [Total Due] by using below DAX Expression 

 

Total Due = LOOKUPVALUE('Table 2'[TotalDue],'Table 2'[ProductID],'Table

 1'[ProductID])

 

Then create a new column for Remaining Amount using below DAX expression,

Remaining Amount = IF('Table 1'[Total Due]-'Table 1'[Paid Amount]>=0,'Table

 1'[Total Due]-'Table 1'[Paid Amount],0)

Output.png

Regarding second question to find non-matching records from table 2 you can create new column in Table 1 with below DAX expressions:

ExistInTable2 = IF(ISBLANK(LOOKUPVALUE('Table 2'[ProductID],'Table 2'[ProductID], 'Table 1'[ProductID])), "No","Yes")

 

And to display only records which are not present in Table 2 you can apply filter on the table visual as ExistInTable as “No”.

Please refer to the below screenshot for the same,

second output.png

If this answer helps, please mark it as Accepted Solution so it would help others to find the solution.


Thanks!

Inogic Professional Service Division

An expert technical extension for your techno-functional business needs

Power Platform/Dynamics 365 CRM

Drop an email at crm@inogic.com

Service:  http://www.inogic.com/services/ 

Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.