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
tsql_simon
Helper I
Helper I

Sum If Header Table Value <> Sum of Details Table Values

SO I have two tables Bills and Payments, Each customer has One bill and they pay it off in stages over the Year, I am trying to get to the amount Unpaid BUT not count any bills which may have been over paid.

CustomerBills

Customer IDBill Amount
1100
2150
3120
4110
5200

 

CustomersPayment

Customer IDPaid Amount
150
150
250
250
3120
450
450
410
550
550
550
575

 

I need to get to 50 Overdue and not the total sum which shows as 25 (Customer 5 is over paid)

 

Thanks in advance

Simon

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @tsql_simon ,

 

not sure if I understand your requirement 100%.

I created the following 2 measures, this is more a habit than necessary for the solution:

 

Total Bill Amount = SUM('CustomersBill'[Bill Amount]) 

 

and

 

Total Paid Amount = SUM('CustomersPayment'[Paid Amount])

 

 

After this I created the following measure that now provides the solution (at least from my understanding of your requirement):

 

Overdue Amount = 
SUMX(
    VALUES(CustomersBill[Customer ID])
    , var billed = [Total Bill Amount]
    var paid = [Total Paid Amount]
    var diff = billed - paid
    return
    IF(diff > 0 , diff , BLANK())
)

 

This allows to a create a report like this:

image.png

 

Hopefully this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey @tsql_simon ,

 

not sure if I understand your requirement 100%.

I created the following 2 measures, this is more a habit than necessary for the solution:

 

Total Bill Amount = SUM('CustomersBill'[Bill Amount]) 

 

and

 

Total Paid Amount = SUM('CustomersPayment'[Paid Amount])

 

 

After this I created the following measure that now provides the solution (at least from my understanding of your requirement):

 

Overdue Amount = 
SUMX(
    VALUES(CustomersBill[Customer ID])
    , var billed = [Total Bill Amount]
    var paid = [Total Paid Amount]
    var diff = billed - paid
    return
    IF(diff > 0 , diff , BLANK())
)

 

This allows to a create a report like this:

image.png

 

Hopefully this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens ;

 

You understood perfectly, Thank you very much, I have been fighting with similar SUMX logic but could not piece it together quite right. That works perfectly for me.

 

Kindest Regards

Simon 

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.