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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Super User
Super User

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
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

View solution in original post

1 REPLY 1
SamInogic
Super User
Super User

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
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.