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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Trebor84
Helper II
Helper II

Append empty table

Hi,

 

I have an issue when trying to append two tables in Power Query.

 

I have two tables that are both linked to SharePoint folders and both queries pull in all files from each sub directory.

On a daily basis we have ongoing work files (table1) and completed work (table2).

 

Before I import any new queries each day, I get a unique list of job ID’s by appending both of these tables then remove duplicate ID’s,


The problem I have is that there isn’t always ongoing work files in the folder so if the folder is empty then it breaks the query due to the table being empty and I receive the below error.

 

An error occurred in the ‘Sample File (3)’ query. Expression.Error: There weren't enough elements in the enumeration to complete the operation.

 

This then prevents me appending table 1 to table 2.

 

Is there any way I can prevent this from happening so if table 1 is empty then it doesn’t do the append step? I have read that a try...otherwise statement might help?

 

The problem is that as the table returns the above error I can’t even see it when I bring up the append window as Power Query doesn’t list the table (table1).


I’m not trying to create a new table, just trying to append table1 data into table2.

 

Any suggestions please?

2 REPLIES 2
jennratten
Super User
Super User

Hello - this is a common problem.  I handle this by including a sample data table (not loaded) that has all of the elements that would be required to make the queries execute successfully, but contains a keyphrase or value which is specifically used to remove the sample rows after processing is complete.  Based on the task at hand, it sometimes makes sense to append the sample data table right from the start and then filter it out at the end.  In other scenarios, it may make sense to conditionally append the tables based on whether or not the actual table has rows, or simply use one or the other using try/otherwise.  The construct of my sample data table is the same regardless of which scenario is encountered and I usually create the sample data table by copying some of the rows from a real table and pasting it into a new table, then changing the values.

I hope this info helps!  Please let me know if you have any questions.

NikhilChenna
Continued Contributor
Continued Contributor

Hi @Trebor84 ,

You cannot keep the table empty , it will not work and give you error. 

 

Regards,

Nikhil Chenna

 

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors