Forum Discussion

WalterM91's avatar
WalterM91
Copper Contributor
Jul 12, 2023
Solved

Duplicate values in a column when another column has duplicated values

Hi, I would need your kind support on a matter regarding the Power Query Editor for an Excel file I am developing.   I have a table as follows:    ID    |    Letter   |    Value    001  |       ...
  • SergeiBaklan's avatar
    Jul 12, 2023

    WalterM91 

    As variant

    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        names = Table.ColumnNames( Source ),
        #"Changed Type" = Table.TransformColumnTypes(
            Source,
            {
                {"ID", type text},
                {"Letter", type text},
                {"Value", Int64.Type}
            }),
        #"Grouped Rows" = Table.Group(
            #"Changed Type",
            {"Letter"},
            {
                {"Data",
                    each [
                        tblOrder = Table.Sort(_,{{"ID", Order.Ascending}}),
                        fillUp = Table.FillUp(tblOrder,{"ID"}),
                        getRow = Table.FirstN( fillUp, 1 )
                    ][getRow]
                     
                }
            }),
        keepData = Table.SelectColumns(#"Grouped Rows",{"Data"}),
        expandData = Table.ExpandTableColumn(
            keepData,
            "Data",
            names, names)
    in
        expandData

    Please check attached.

Resources