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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
chriswragge
Helper I
Helper I

Create multiple tables from single query

Hi there,

 

I have 20 differing queries all essentially referencing the same basic code.

 

= #"Base Code - New"(startDateNew, endDateNew, "at")

 

"Base Code - New" is a function that takes in 3 vars. startDateNew and endDateNew are parameters, and the last var is a country code that changes.  This means that I have 20 queries, all with a different 3rd var.

 

e.g. 

 

= #"Base Code - New"(startDateNew, endDateNew, "be")
= #"Base Code - New"(startDateNew, endDateNew, "ca")

and so on...

 

 

What I would like to do is combine these 20 queries into a single query in order to simplifiy my code. Is this possible?

Note - All queries produce the same column headers and data types

 

Bonus points: Even though this post title doesn't explicitely state it, an even better solution (my next question) would be how to union all of these tables into a single table through the query editor. This way I would would have one query producing one table from 20 different sources via a function.

 

Thanks!

1 ACCEPTED SOLUTION

Sorry Xiaoxin - duplicate post that I cannot delete now. Please see this link for my accepted solution

https://community.powerbi.com/t5/Desktop/Create-multiple-tables-from-single-query/td-p/412254 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

HI @chriswragge,

 

I"d like to suggest you create a table to store parameters, then add custom column to invoke and store result tables from custom function.

 

After these steps, use Table.Combine function to merge tables from above result table list.

 

Reference links:

Table.Combine

Creating Tables In Power BI/Power Query M Code Using #table() 

 

Regards,

Xiaoxin Sheng

Sorry Xiaoxin - duplicate post that I cannot delete now. Please see this link for my accepted solution

https://community.powerbi.com/t5/Desktop/Create-multiple-tables-from-single-query/td-p/412254 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.