Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
ChrisDurham
Frequent Visitor

Use a list of tables in Table.Combine

I have a table with a column of table names in it - over 150. I want to select specific rows from each of these tables and then append them all together into a single table. I know I need to use Table.Combine to append the tables together but how do I first filter the data in each table and then pass that to the Combine function? ie

 

for each tableName in myTables

     load data from table referenced by tableName

     filter data

     append filtered data to outputTable

loop

 

If it's easier I may be able to simply append each table in the list together and then filter at the end however there could be several million records in total. 

 

Can anyone help?

     

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Suppose you have queries Query01, Query02, and Query03 loaded into the query editor and a query called "Tables" that lists these in a single column Tables[TableName].

AlexisOlson_0-1672766103233.png

 

You can use the #shared environment to return a table of these tables as follows:

 

 

Record.ToTable(Record.SelectFields(#shared, Tables[TableName]))

 

 

AlexisOlson_1-1672766190642.png

 

You can apply a filter condition to each table. For example, choose rows where ColA is non-null.

 

 

= Table.TransformColumns(
      TablesToCombine,
      {{"Value", each Table.SelectRows(_, each [ColA] <> null), type table}}
  )

 

 

Once filtered, you can then expand the [Value] column to get your final result.

 

Here's an example of the full query:

 

 

let
    TablesToCombine = Record.ToTable(Record.SelectFields(#shared, Tables[TableName])),
    #"Filter Tables" = Table.TransformColumns(TablesToCombine, {{"Value", each Table.SelectRows(_, each [ColA] <> null), type table}}),
    #"Cols to Expand" = Table.ColumnNames(Query01),
    #"Expanded Value" = Table.ExpandTableColumn(#"Filter Tables", "Value", #"Cols to Expand", #"Cols to Expand")
in
    #"Expanded Value"

 

 

View solution in original post

1 REPLY 1
AlexisOlson
Super User
Super User

Suppose you have queries Query01, Query02, and Query03 loaded into the query editor and a query called "Tables" that lists these in a single column Tables[TableName].

AlexisOlson_0-1672766103233.png

 

You can use the #shared environment to return a table of these tables as follows:

 

 

Record.ToTable(Record.SelectFields(#shared, Tables[TableName]))

 

 

AlexisOlson_1-1672766190642.png

 

You can apply a filter condition to each table. For example, choose rows where ColA is non-null.

 

 

= Table.TransformColumns(
      TablesToCombine,
      {{"Value", each Table.SelectRows(_, each [ColA] <> null), type table}}
  )

 

 

Once filtered, you can then expand the [Value] column to get your final result.

 

Here's an example of the full query:

 

 

let
    TablesToCombine = Record.ToTable(Record.SelectFields(#shared, Tables[TableName])),
    #"Filter Tables" = Table.TransformColumns(TablesToCombine, {{"Value", each Table.SelectRows(_, each [ColA] <> null), type table}}),
    #"Cols to Expand" = Table.ColumnNames(Query01),
    #"Expanded Value" = Table.ExpandTableColumn(#"Filter Tables", "Value", #"Cols to Expand", #"Cols to Expand")
in
    #"Expanded Value"

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors