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
aflintdepm
Helper III
Helper III

Sum of Balance by Account

I have a list of customers who have multiple claims connected to their account.  I need to calculate the total outstanding balance across all claims, by account number.

 

In Excel, I would just do a pivot table by account number with a sum of the balance.  For some reason, when I do this in PBI, it is giving the the total balance for the entire roster, not a per-patient sum.  What am I missing?

 

Data samples:

Patient List (unique, no duplicates, for relationships)

PatientNameAccountNumber
John Smith12345
Bob Jones23456
Nancy Lewis54321
Barbara Taylor98765

 

AccountBalances

This is the Many side of the relationship

AccountNumberClaimNoBalance
123454556$45.00
234564557$65.00
123454558$30.00
234564559$25.00
543214560$50.00
987654561$75.00
543214562$40.00
987654563$25.00

 

My desired output would look like this:

PatientNameBalance
John Smith$75.00
Bob Jones$90.00
Nancy Lewis$90.00
Barbara Taylor$100.00

 

I'm sure I'm missing something obvious, so all help is appreciated.

1 ACCEPTED SOLUTION
v-jianpeng-msft
Community Support
Community Support

Hi, @aflintdepm 

I'm happy to answer your questions. You can use the SUMMARIZE function to get the results you want. Based on the data you provided, I created the following two tables:

vjianpengmsft_0-1708516622737.png

vjianpengmsft_1-1708516637483.png

I created a new table with the results you are expecting by subtotaling the following DAX expression:

Table = SUMMARIZE('Patient List','Patient List'[PatientName],"Balance",CALCULATE(SUM(AccountBalances[Balance]),FILTER('AccountBalances','AccountBalances'[AccountNumber]='AccountBalances'[AccountNumber])))

The results are as follows:

vjianpengmsft_2-1708516976483.png

In the above DAX expression, you can understand it this way: the first parameter is the table that needs to be summarized, the second parameter is to extract the non-duplicate columns in this table, the third parameter is the column name of the summary column, and the fourth parameter The first parameter is the expression of this summary column. In this expression, I sum the Balance in the AccountBalances table and filter out rows with the same AccountNumber through the Filter function. For detailed DAX usage, you can click on the link below to learn and practice.

https://dax.guide/summarize/

https://dax.guide/filter/

https://dax.guide/calculate/

I have provided the PBIX file used this time below. If it can inspire you, that would be great.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

3 REPLIES 3
v-jianpeng-msft
Community Support
Community Support

Hi, @aflintdepm 

I'm happy to answer your questions. You can use the SUMMARIZE function to get the results you want. Based on the data you provided, I created the following two tables:

vjianpengmsft_0-1708516622737.png

vjianpengmsft_1-1708516637483.png

I created a new table with the results you are expecting by subtotaling the following DAX expression:

Table = SUMMARIZE('Patient List','Patient List'[PatientName],"Balance",CALCULATE(SUM(AccountBalances[Balance]),FILTER('AccountBalances','AccountBalances'[AccountNumber]='AccountBalances'[AccountNumber])))

The results are as follows:

vjianpengmsft_2-1708516976483.png

In the above DAX expression, you can understand it this way: the first parameter is the table that needs to be summarized, the second parameter is to extract the non-duplicate columns in this table, the third parameter is the column name of the summary column, and the fourth parameter The first parameter is the expression of this summary column. In this expression, I sum the Balance in the AccountBalances table and filter out rows with the same AccountNumber through the Filter function. For detailed DAX usage, you can click on the link below to learn and practice.

https://dax.guide/summarize/

https://dax.guide/filter/

https://dax.guide/calculate/

I have provided the PBIX file used this time below. If it can inspire you, that would be great.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Datastronaut
Frequent Visitor

Hi,

Did you check if the relationship has been created in the model view ?

Datastronaut_0-1708449935745.png

 

Yes, and I verified it is 1:Many

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.