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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jeffs9876
New Member

Merge two tables while summing values from subtable

Hello, I have two tables

 

Table A is the Payment Table

Payment IDPayment AmountPayment Date
1101/1/17
2101/2/17
3101/3/17
4101/4/17
5101/5/17
6101/6/17

 

 

Table B is the Refund Table

Refund IDPayment IDRefund AmountRefund Date
a151/1/17
b151/2/17
c231/3/17
d231/4/17
e231/5/17
f321/6/17

 

I would like to merge them together to get Table C which is the Payment Table (Table A) with the total refunds for each payment from the Refund Table (Table B) summed up into the new Refund Amount column 

 

Table C - Required Result

Payment IDPayment AmountPayment DateRefund Amount
1101/1/1710
2101/2/179
3101/3/172
4101/4/170
5101/5/170
6101/6/170

 

Currently when I merge these I get the following which is wrong as it creates multiple payment ID rows for each refund amount. 

Payment IDPayment AmountPayment DateRefund Amount
1101/1/175
1101/1/175
1101/1/173
2101/2/173
2101/2/173
3101/3/172
4101/4/170
5101/5/170
6101/6/170

 

Thank you in advance for your help.

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

Hi @jeffs9876,

 

According to your description above, adding a calculate column in Payment Table should be a better choice than merging the two tables in your scenario. Smiley Happy

 

1. Create a relationships between the Payment table and Refund table with the Payment ID column if there isn't yet.

 

relationship1.PNG

 

2. Then you should be able to use the formula below to add a new calculate column in Payment table to get the total refunds for each payment from the Refund Table.

Refund Amount = CALCULATE(SUM(Refund[Refund Amount])) + 0

c2.PNG

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @jeffs9876,

 

According to your description above, adding a calculate column in Payment Table should be a better choice than merging the two tables in your scenario. Smiley Happy

 

1. Create a relationships between the Payment table and Refund table with the Payment ID column if there isn't yet.

 

relationship1.PNG

 

2. Then you should be able to use the formula below to add a new calculate column in Payment table to get the total refunds for each payment from the Refund Table.

Refund Amount = CALCULATE(SUM(Refund[Refund Amount])) + 0

c2.PNG

 

Regards

Perfect! Thank you.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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