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

Working with Duplicate Rows

I am trying to create a report to reconcile charges with payments.  This is a healthcare environment that generates 2-3 charges for each claim, depending on the number of insurances.  Unfortunately, the billing system does not assign a unique charge number or indicate who the charge is going to.  Here is an example:

Claim    Name             Amount

12345John Smith250
12345John Smith250
12345John Smith250
45678Bob Jones300
45678Bob Jones300
45678Bob Jones300

 

In this example, each patient has a Primary Insurance, a Secondary Insurance, and a Co-pay.  Each row represents a claim to each of those payment sources.

 

On the payment side, I need to reconcile how many payments have been received and if there is an outstanding balance

 

Claim     Name             Payment

12345John Smith100
12345John Smith100
12345John Smith40
45678Bob Jones100
45678Bob Jones100

 

Using this sample data, John Smith/12345 has an outstanding balance of $10, while Bob Jones/45678 has an outstanding balance of $100.

 

I would like my final table to look something like this:

aflintdepm_0-1702052785008.png

Thank you in advance for any advice

 

1 ACCEPTED SOLUTION
marcelsmaglhaes
Super User
Super User

Hey @aflintdepm ,

You will need some DAX measures and a correct data model. See the attached pbix example.

marcelsmaglhaes_0-1702066758276.png

 


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1702097707804.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
marcelsmaglhaes
Super User
Super User

Hey @aflintdepm ,

You will need some DAX measures and a correct data model. See the attached pbix example.

marcelsmaglhaes_0-1702066758276.png

 


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



Thank you for the example file- this was very helpful.  I just have a couple of questions

First- am I correct in my understanding that you created the third table to remove the duplicates and give a single lookup table? 

 

Second- could you please explain the structure of the Charge measure you created?  I don't understand the nested CALCULATE(VALUES without a filter expression)

Charge =
SUMX(
    VALUES(Charge[Claim]),
    CALCULATE(
        VALUES(Charge[Amount])
    )
)
 
I'm going to work to recreate this on the larger datatables that I am working with.  Thank you

Hey @aflintdepm !


1. Yes. I put the data into a star schema model perspective

2. The CALCULATE function changes the context of the calculation. Inside the CALCULATE, we use VALUES(Charge[Claim]) to get a table with the unique values of the "Claim" column. The absence of a filter expression in CALCULATE means it operates in the current filter context established by the outer SUMX.


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



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.