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.
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:
Here is an example when the query returns a series of results:
Here is an example when there is no data and PowerBI throws an error:
Here is the script that is attempting to be run:
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!
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.
Familiarize yourself with the "try ... otherwise ...." concept in Power Query - that will help you to handle such a situation.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.