SOLVED

Power Query merging query creating duplicate rows

Copper Contributor

I've successfully merged tables and data integrity has remain stable until my last query merge step.  In some instances it has duplicated or tripled the line data and I don't know why.  Does someone know why?

 

ie:  SKU:  aaa-aa-aa-nn    15000

table merging contains sku, sku classification, sku status

 

My goal is to import the sku classification and sku status but when I merge the table it's repeating the lines.  I've been able to determine one specific sku but don't know why it is happening when my other merges have been successful.  Any assistance would be appreciated.

4 Replies

@CathyPulido Difficult to diagnose without seeing the data (both tables) and the steps applied.

@Riny_van_Eekelen 

 

I will try my best to explain my situation in a few words and I will attach an archive with some files (I have anonymized the real data for security reasons).

I need to prepare a report that will allow me to see the billing for a contact center with multiple clients.

  I`m struggling to get the report finished because I get duplicate rows after merging two appended queries.

 I have tried in two ways:

 

  1. Get data from a folder (12 xlsx files with two sheets, one sheet with the number of agents and cost of the licensing and another sheet with the cost of the outgoing/incoming calls charges). I have created two queries for each of the sheets and after that I have merged this two n a separate query. Everything looks fine up until I get to the merged query were all the data gets duplicated multiple times.
  2. Get data from each xlsx files and create 2 append query for each of the sheets in every xlsx file and then merge the two appended queries. Here I could see the same behavior.

  Thank you!

best response confirmed by Hans Vogelaar (MVP)
Solution

@adrianmihaita Your query merges the two other based on License ID alone. Since you have 13 periods (Year-Month) for each license, PQ will create 13 X 13 = 169 rows for each one. You need to base the merge (LeftOuter) on Licence ID, Year and Month.

 

First select License ID in both left and right, then press and hold Ctrl and select Year in both and then Month in both. LeftOuter and OK. Expand the relevant columns from the merged tables and you get the billing report, one row for each license, year and month. Thus, 13 rows for each license.

 

@Riny_van_Eekelen thank you for point out the obvious fact ... now it makes sense! :)

Thank you very much for your prompt and fast reply

1 best response

Accepted Solutions
best response confirmed by Hans Vogelaar (MVP)
Solution

@adrianmihaita Your query merges the two other based on License ID alone. Since you have 13 periods (Year-Month) for each license, PQ will create 13 X 13 = 169 rows for each one. You need to base the merge (LeftOuter) on Licence ID, Year and Month.

 

First select License ID in both left and right, then press and hold Ctrl and select Year in both and then Month in both. LeftOuter and OK. Expand the relevant columns from the merged tables and you get the billing report, one row for each license, year and month. Thus, 13 rows for each license.

 

View solution in original post