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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Grouped Tables - Merged. but creating duplicate rows.

Hello,

 

I have two grouped tables that i have merged together into one.  Both tables have different row counts.  When i merge them together, matching on a patient health card number it is creating duplicates in one of the grouped tables.  See pictures below.

 

given_0-1729857692208.png

The highlighted column is the one that is duplicating.  I only want to count the highlighted column once, compared to the right hand side.  It is duplicating because of how many more dates (visits) are on the right.  

 

Any help would be greatly appreciated! or maybe there is an alternative solution and merging is not the answer!

 

 

7 REPLIES 7
OktayPamuk80
Responsive Resident
Responsive Resident

Hi,

The issue is that a patient can come to outpatient visit couple of times and may come to emergency visit one or many times. It would be good to bring them over a case Id together (the Id that one HCN receives when coming to hospital. Another suggestion is not to merge them but append the to visit:

 

HCNTypeDate InDate Out
1outpatient2024/10/272024/10/27
1emergency2024/10/282024/10/29
2outpatient2024/09/20242024/09/2024

 

Of course, the outpatient records will always have the same date in and date out value however, by this you can plot them more easily. The additional case Id, would make it easier to identify, whether the different visits correlate to each other.

 

Regards,
Oktay

 

Did I answer your question? Then please mark my post as the solution.

If I helped you, click on the Thumbs Up to give Kudos.

Anonymous
Not applicable

Hi Oktay,

 

Thank you for all of your input.  We did the Unique Identifying Case ID in excel yesterday (very manualy).  We are anticipating to have to update this data at some point.  Do you think assigning the Case ID in excel is the way to go and then upload to Power BI or is there a way/formula to assign a Case ID to a specific Number (HCN)? 

 

Thanks,

Denise

Hi,

This is strange. In my opinion it should be in the process of the emergency visit, to determine, that based on outpatient visit, the emergency visit emerged. Can't you have this implemented in the ERP system in the emergency room system? for the same patient you open a new case anyway and you need to select from previous cases, that it is still the same case (or relating to the existing one). By this, you can have multiple facts table including common master data (patient, calendar, etc.)

 

Regards,
Oktay

 

Did I answer your question? Then please mark my post as the solution.

If I helped you, click on the Thumbs Up to give Kudos.

 

Regards,

Oktay

Anonymous
Not applicable

Hi @Anonymous ,

Based on the description, selecting the Left outer when merging two tables.

vjiewumsft_0-1730085376400.png

vjiewumsft_1-1730085385109.png

You can also view the following document to learn more information.

Left outer join - Power Query | Microsoft Learn

Merge queries overview - Power Query | Microsoft Learn

 

Best Regards,

Wisdom Wu

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

OktayPamuk80
Responsive Resident
Responsive Resident

Hi,

I suppose in your example, one of your tables is the HCN and registration date (patient master table) and the other one is about the visits. The visits table is the facts table and I advice you not to merge them. Leave them as single tables and connect them in the model view. If however, you need specific fields then merge only requiring fields to make sure the HCN master table does not get duplicate records. What are you trying to achieve? What is the reason for merge (keep in mind, Star-schema is still the best data model option for Power BI).

Regards,
Oktay

 

Did I answer your question? Then please mark my post as the solution.

If I helped you, click on the Thumbs Up to give Kudos.

Anonymous
Not applicable

Also, if i leave them as individual tables and try to connect by HCN i am getting errors because neither are unique and there are duplicates.. hence why i tried merging them

 

Anonymous
Not applicable

Hi Oktay,

 

Thanks for getting back to me!  I did try the Left Outer Join with the merge with no success.. leaving them as single tables.  We are trying to look at the outpatient visits that followed with an Emergency Visit.  The unfortunate part is that the Emerg Reg Dates will differ from the outpatient visits Reg Dates and the only commonality to tie them together is the HCN.  We are looking to see how many days after an outpatient visit it took them to go to the Emergency Room.    We will have lots of outpatient visits that follow an Emergency Visit.  Any other advice would be greatly appreciated! I feel I am stuck!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.