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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
RedWineGirl
Advocate I
Advocate I

Scheduled report failing as no data during school holidays

We have scheduled daily reports from our MIS system into PowerBI. One of the reports is 'student attendance today' so there is no data in holidays so the refresh fails and the schedule stops. Is there a way I can code straight after Source to ignore empty tables?

Thanks

1 ACCEPTED SOLUTION

Alright. Now I'm getting the idea. You don't own the source, it's a web income similar to an API. You just have a single url. When the data is not there it fail and doesn't return anything.

The best approach for getting data from API or URL would be building a warehouse or lakehouse to build a history data. Just for you to keep in mind.

For now, you can use power query code to capture failures. Depending in which step the error is thrown, the solution can change. 

  • Error at web content: you can handle it with parameters of the method if you know the code error of the request. For example:

 

= Csv.Document( 
    Web.Contents("https://raw.githubusercontent.com/ibarrau/PowerBi-code/refs/heads/master/DatosPrueba/ProductCategoryaa.csv" 
        , [ManualStatusHandling={404, 400}]
    ) ,[Delimiter=";", Columns=2, Encoding=65001, QuoteStyle=QuoteStyle.None] 
)​

 

That example will return a table with a two column (like csv specify) with the error when the webcontent fails for 404 or 400.

Then as the otherwise result you can build an empty tables with the same column names of a traditional result with: https://learn.microsoft.com/en-us/powerquery-m/sharptable

 

try [Code that throw error] otherwise #table({"Column1", "Column2"})​

 

That should handle the error to prevent the fail when refreshing and just return an empty table.

I hope that make sense


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

Happy to help!

LaDataWeb Blog

View solution in original post

8 REPLIES 8
v-yohua-msft
Community Support
Community Support

Hi, @RedWineGirl 

Have you solved your problem? If so, can you share your solution here and mark the correct answer as a standard answer to help other members find it faster? Thank you very much for your kind cooperation!

 

Best Regards

Yongkang Hua

RedWineGirl
Advocate I
Advocate I

The report in Bromcom (a csv that we use as a live feed) only shows lessons today - we can't say within a period - it's all data (we have volume issues) or just today so when I run the report it's blank. The PowerBI error is 

..There weren't enough elements in the enumeration to complete the operation.. #table({"Name", "Table"}, {}). </ccon>;<ccon>There weren't enough elements in the enumeration to complete the operation.</ccon>. The exception was raised by the IDbCommand interface. Table: G Todays Student

 

so it's correct in having no data but that stops the refresh.  

I'm looking at building an alternative report if need be.

Ok. I'm still a bit confused. What is the data souce for power bi? which connector are you using for getting csv?

In my mind if you are creating a csv by day, you can connect using "Folder" connector. That way it shouldn't fail if you don't add a new day at the folder.

If you are connecting with the Csv connector. Then consider "adding rows and not replacing" when a new day is here.

I'm sorry I'm talking general scenarios but I'm not sure how you are connecting the data yet to talk alternatives for preventing the failed refresh.

Regards


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

Happy to help!

LaDataWeb Blog

We take data from Bromcom, we create reports and there is the option for a live feed, so we have a URL that pulls the data straight from the MIS into PowerBI - using Web connector.  As there is no data (live classes today) when the system pulls the data from the MIS, there isn't any data. Hope that makes sense.

Alright. Now I'm getting the idea. You don't own the source, it's a web income similar to an API. You just have a single url. When the data is not there it fail and doesn't return anything.

The best approach for getting data from API or URL would be building a warehouse or lakehouse to build a history data. Just for you to keep in mind.

For now, you can use power query code to capture failures. Depending in which step the error is thrown, the solution can change. 

  • Error at web content: you can handle it with parameters of the method if you know the code error of the request. For example:

 

= Csv.Document( 
    Web.Contents("https://raw.githubusercontent.com/ibarrau/PowerBi-code/refs/heads/master/DatosPrueba/ProductCategoryaa.csv" 
        , [ManualStatusHandling={404, 400}]
    ) ,[Delimiter=";", Columns=2, Encoding=65001, QuoteStyle=QuoteStyle.None] 
)​

 

That example will return a table with a two column (like csv specify) with the error when the webcontent fails for 404 or 400.

Then as the otherwise result you can build an empty tables with the same column names of a traditional result with: https://learn.microsoft.com/en-us/powerquery-m/sharptable

 

try [Code that throw error] otherwise #table({"Column1", "Column2"})​

 

That should handle the error to prevent the fail when refreshing and just return an empty table.

I hope that make sense


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

Happy to help!

LaDataWeb Blog

Thanks - that makes sence!

ibarrau
Super User
Super User

Hi. Empty tables shouldn't fail. That sounds like it can't find the source. Are you replacing the data everyday? I mean, are you only showing 1 single data at the dataset? can you share a picture of the error in power bi desktop and the data model so we can help capturing this error and keeping the refresh working?

Regards.


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

Happy to help!

LaDataWeb Blog

Apologies for the delay in replying...haven't had time to check as yet!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.