Search code examples
excelpowerbipowerquerypowerbi-desktopm

how to add a fixed column in power query?


I have a few huge datasets and I want to append them together. To not lose the data source name (bla), I would like to add in 1 column, of each data set, the data source name (bla). Many thanks in advance.

Expected Result using M language.

Date       Amount   data.source
1/1/2020   20         bla
1/1/2020   20         bla
1/1/2020   20         bla

Solution

  • Here, TableA and TableB are two source queries (your huge datasets) and a column is added to each before appending.

    let
        Source = Table.Combine({ Table.AddColumn( TableA, "data.source", each "TableA"), Table.AddColumn( TableB, "data.source", each "TableB")})
    in
        Source