Forum Discussion

some_analyst's avatar
some_analyst
Helper I
1 year ago
Solved

Appending query to itself, keeping previous rows

I have a power Query set up which pulls data from Sharepoint List. I do my transformations there and end up with 4 rows, one of which is a column I created, today's date. This loads to Excel. How c...
  • Riny_vE's avatar
    1 year ago

    Imagine the weekly update is like in the blue table (screenshot below) and the combined one from earlier updates is the green one and comes from an earlier run of the query

     

    The following M-code will connect to tblSource (Source)  AND tblPQ (History) and then append Source to History to create an extended tblPQ.

    let
        Source = Excel.CurrentWorkbook(){[Name="tblSource"]}[Content],
        History = Excel.CurrentWorkbook(){[Name="tblPQ"]}[Content],
        #"Appended Query" = Table.Combine({History, Source}),
        #"Changed Type" = Table.TransformColumnTypes(#"Appended Query",{{"Snap", type date}, {"ID", type text}})
    in
        #"Changed Type"

    It results in this:

    and a next run may look like this:

     etc.