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
Surfacescan
Helper I
Helper I

Importing sometimes empty XML table - Expression.Error: There weren't enough elements

 Hello - I am building a storm tracker and I want to elegantly handle when there is no XML data tables because the query returns an empty result. At the moment it throws an error:

 

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

 

I connect to the XML datasource using Web Connector and the service is Earth Networks.  I pass the latitude and longitude for the query in the url like this: 

 

https://api.lxalerts.earthnetworks.com/CellAlerts.aspx?nwlat=-14.68245&nwlon=43.16110&selat=-22.3124...

 

Here is an example when the query returns a series of results:

Annotation 2020-07-16 074801.png

Here is an example when there is no data and PowerBI throws an error:

 

 

Annotation 2020-07-16 074715.png

Here is the script that is attempting to be run:

Annotation 2020-07-16 074636.png

Grateful if anyone can suggest how to handle this better.  Ideally I would like to display text on my map when there are no storms (empty result) such as:

 

"There are no storms to report at this time"

 

Thanks!

 

2 REPLIES 2
v-alq-msft
Community Support
Community Support

Hi, @Surfacescan 

 

The reason for the error message is that a  column name you were referring to wasn't in the particular xml file you were using. I'd like to suggest you use Table.Isempty() function to check if the table is empty. If it is not empty, then you can refer to the column in the table and do some transformations. Or you can refer to Error Handling to troubleshoot the error.

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Familiarize yourself with the "try ... otherwise ...." concept in Power Query - that will help you to handle such a situation.

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