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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
PowerNils
Regular Visitor

Append Queries as New will result in no query folding

Dear fellow BI'ers,

 

I have a really strange behaviour when appending queries as new.

 

In my scenario, I have one source (SQL Server) to whom I connect. This source has several companies within it. Always with CompanyName$TableName as the table name. I then filter the tables to show me only a specific table. Lets say Sales. I will get a list of the Sales table from all companies. I will add those to my Queries with "Add as New Query". Afterwards, I will delete the filter step between Source and Navigation. Then, I will add a column called Company with the respective company name. Until now, I can see the native query.

 

If I then take the first query and click on "Append Queries as New" and append all of them together, the new Source will not be able to show me the native query. To confirm, that no query folding occurred, I will make diagnostics. This confirms that there is no query folding.

 

When I take the first query and click "Append Queries" and take exactly the same queries, query folding works.

 

This is new behavior that I haven't seen before. Can you help me how this happens and how this can be changed???

 

Thanks,

PowerNils

3 REPLIES 3
SH_SL
Frequent Visitor

Hey, im hijacking your question since im trying to replicate the query folding you did with "Append Queries".
I have two tables from one SQL server but two different databases.
For each query the query folding works. If i try to append the tables (like this: #"Appended Query" = Table.Combine({ThisTable, OtherTable}) query folding won't work from that point forward. Am I missing something or is it not possible?
Found the answer here:
https://community.powerbi.com/t5/Power-Query/How-to-Achieve-Power-Query-folding-with-Append-Quires/t...

willcisler
Frequent Visitor

To preserve native query in a new query try:

 

Go to thefirst query and click "Append Queries" - like you did in your 1st example

then right click on the Appended Query step and choose  the 'Extract Previous' option 

 

That seems to preserve the native query - I was actualy trying to break the link when I found your post.

 

Good luck

lbendlin
Super User
Super User

Compare the generated M code between the two approaches. 

 

Append as new:

let
Source = Table.Combine({FirstTable, SecondDTable})
in
Source

 

Append :

#"Appended Query" = Table.Combine({ThisTable, OtherTable})

 

So - technically there's no difference.  Maybe query folding doesn't like to work with references only.

 

Having said all this - have you considered doing the UNION ALL at the source, ie with a custom SQL query?

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors