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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
crossover
Advocate I
Advocate I

Suppressing blank query error message

Happy new year!

 

I realize it's PowerBI board, however I'm running PowerQuery for Excel purposes, but perhaps it doesn't play a big role. My PQ query loads xlsm files from a folder - which sometimes can be empty. The query fetches some named-range data from xlsm files to display and looks like this is where I run into issues. If there's nothing present, I'd like to receive a nice and civilized blank response, however once the query reaches M-code lines that fetch named range data, I'll get an error message that will result in a popup message (again - in a scenario when folder is empty):

[Expression.Error]: There weren't enough elements in the enumeration to complete the operation.

 

This also interrupts a scheduled process with this popup. On full disclosure: I launch this query from Excel via VBA-script and I could suppress this message by adding a "On Error Resume Next" command, though I wouldn't want to turn off error messaging fully.

 

The question to this board - is there a way to configure the query itself to just display blank result and not add the popup when the result is just a blank page? Looks like fetching specific data from inside the workbook is where things get derailed, before that line, I'll just get blank result when stepping through the M-code lines:

#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Errors1", "Transform File (9)", Table.ColumnNames(#"Transform File (9)"(#"Sample File (9)"))),

 

(there are several named-range data extractions, this is just the first one)

 

Thanks a lot!

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @crossover 

 

you can use the error handler "try" and "otherwise".  so you could a statement like this

YourFinalResult = try Table.ExpandColumn(.....) otherwise YourExpectedResultWhenHittingAnError


If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

1 REPLY 1
Jimmy801
Community Champion
Community Champion

Hello @crossover 

 

you can use the error handler "try" and "otherwise".  so you could a statement like this

YourFinalResult = try Table.ExpandColumn(.....) otherwise YourExpectedResultWhenHittingAnError


If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Top Kudoed Authors