Forum Discussion

o59393's avatar
o59393
Icon for Post Prodigy rankPost Prodigy
6 years ago
Solved

Merged queries is duplicating values

Hi all   I need to add a column from one table to another using merge queries in Power query, in order to go from this is in table called "lines"    to this:   As seen, each of the ...
  • AllisonKennedy's avatar
    6 years ago
    You have 'Cardboard' and 'Plastic' in your Month and Units table, so you get a month for each of those Materials, therefore you're getting 19 months * 3 rows in Lines table * 2 Materials in Month and Units table = 114 rows total.

    I don't really understand why you need to duplicate the rows in the Lines table for each month? Can you use a DimDate table and some measures to achieve this result instead?

    Otherwise try referencing the Month & Units table in a new query, do a Remove Duplicates on the Month column and use that for your merge.

    Advanced Editor M script for the referenced query:

    let
    Source = Table2,
    #"Removed Duplicates" = Table.Distinct(Source, {"Month"})
    in
    #"Removed Duplicates"

    Where Table2 is your Month & units table.

    Then use that new Query (name it DistinctMonths ? or something that makes sense to you) as your second table in the merge.