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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors