Forum Discussion

ctaylor's avatar
ctaylor
Icon for Helper III rankHelper III
6 years ago
Solved

Combining files and updating matching rows

Hello,   I have an excel file that contains a data dump and a weekly emailed file that contains new/updated information.  The data is an export of activity from a help desk, so each week there will...
  • v-lid-msft's avatar
    v-lid-msft
    6 years ago

    Hi ctaylor ,

     

    We can use the following steps to meet your requirement, if your excel has same data construction:

     

    1. keep the content and "data modified" column and remove other

     

    2. expand and combine the content as usual

     

    3. group by the number column and make other as all rows.

     

    4. create a custom column:

     

    Table.Max([Data],{"Data Modified"})

     

     

    5. remove the data column and expand the New Rows Column

     

     

    6. result as following:

     

     

     

    All queries are here (just a sample, did not include the combine file step)

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTKFYiMDIwNdU11DBUMDK2MDKwMDpVidaCUjoIwZFGNXYQyUAWETvCrSoKqgKoxQVZhAZfG7A2RGBnYzYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Number = _t, Location = _t, #"Updated by" = _t, #"Data Modified" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Number", Int64.Type}, {"Location", type text}, {"Updated by", type text}, {"Data Modified", type datetime}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Number"}, {{"Data", each _, type table [Number=number, Location=text, Updated by=text, Data Modified=datetime]}}),
        #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Newest Rows", each Table.Max([Data],{"Data Modified"})),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Data"}),
        #"Expanded Newest Rows" = Table.ExpandRecordColumn(#"Removed Columns", "Newest Rows", {"Location", "Updated by", "Data Modified"})
    in
        #"Expanded Newest Rows"

     

     


    By the way, PBIX file as attached.


    Best regards,