Forum Discussion
Trying to create a new column based on the query or source file name.
- 6 years ago
Hi dmarics28 ,
Try to change the code of your Append query in the Advanced Editor.
let Source = Table.Combine({Table.AddColumn(#"query A", "source query", each "query A") , Table.AddColumn(#"query B", "source query", each "query B") , Table.AddColumn(#"query C", "source query", each "query C")}) in SourceBTW, .pbix file attached.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi dmarics28 ,
1) In Power Query, go to New Source>Blank Query>Advanced Editor and paste this code over the default code:
let
Source = #sections,
Section1 = Source[Section1],
convertTable = Record.ToTable(Section1)
in
convertTableThis will load a table with all components of your Power Query setup.
2) Filter the [Name] column to include only the names of the tables that you want to append. Once you have done this, you will see that the dropdown button in the column header changes to an expand button:
3) Expand this as you would after a Merge/Join including all columns that are the same in both queries:
4) You will then have an appended table which includes the source query name in each:
Pete
For me, this does perfectly the job. Thank you