March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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
Solved! Go to 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.
= 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
Happy to help!
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
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
Happy to help!
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.
= 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
Happy to help!
Thanks - that makes sence!
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.
Happy to help!
Apologies for the delay in replying...haven't had time to check as yet!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
40 | |
26 | |
17 | |
11 | |
10 |
User | Count |
---|---|
58 | |
52 | |
23 | |
14 | |
11 |