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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.