Combine Tables on Power Query Dynamically

Viewed 40

I have several files that are located in a folder on Google Drive so I pull the data for each file into several queries depending on the respective file. The next stage is to combine these tables into a table named DataFull by :

let
    Source = Table.Combine({Query1, Query2, Query3, Query4})
in
    Source

The question is: how to combine the query names dynamically? Such as the name of the query to be merged is taken from the data in the form of a list.

1 Answers

This combines queries specified in a list

let  Source = Record.ToTable(#shared),
TableList=({"Table1","Table3","Table5"}),
#"Filtered Rows" = Table.SelectRows(Source, each List.ContainsAny({[Name]},TableList)),
ColumnsToExpand = List.Distinct(List.Combine(List.Transform(Table.Column(#"Filtered Rows", "Value"), each if _ is table then Table.ColumnNames(_) else {}))),
#"ExpandedThem" = Table.ExpandTableColumn(#"Filtered Rows", "Value",ColumnsToExpand ,ColumnsToExpand )
in #"ExpandedThem"
Related