Forum Discussion
Refresh Error (Service only)
Thankyou, BhavinVyas3003, Nasif_Azam, for your response.
Hi lnedeah,
We sincerely appreciate your inquiry posted on the Microsoft Fabric Community Forum.
Based on my understanding, the primary cause of the error message, “Expression.Error: There weren’t enough elements in the enumeration…”, arises due to the difference in how Power BI Service processes folder queries compared to Power BI Desktop. Specifically, Power BI Service attempts to process one or more files that return incomplete or empty data structures. This issue may not be evident during refresh in Power BI Desktop because of local caching and differing credential contexts.
The issue tends to occur only in the Service environment due to the following reasons:
- The Service does not utilize local cache and may encounter hidden, temporary, or unsupported files in the SharePoint folder (such as .tmp, ~$ files, or blank files).
- Header promotion or transformations applied to empty tables can result in this error during Service refresh.
- Authentication or privacy level mismatches may prevent certain files from being accessed during the Service refresh.
Kindly follow the steps below which may help in resolving the issue:
- In Power Query, filter the folder query to include only the required file types (for example, .xlsx or .csv) and exclude system or temporary files (such as ~$ files or empty files).
- Add error handling and, before promoting headers, use the following expression:
if Table.IsEmpty(Source) then Source else Table.PromoteHeaders(Source) - Verify the credentials in Power BI Service by navigating to Dataset Settings > Data source credentials. Use OAuth2 authentication and ensure that the privacy level is set to “Organizational”.
- Ensure consistency in the file structure by maintaining identical columns and headers across all files in the folder.
- Re-publish the report after making the necessary adjustments and reconfigure the credentials accordingly.
Additionally, please refer to the following links for further guidance:
Power Query SharePoint folder connector - Power Query | Microsoft Learn
Data refresh in Power BI - Power BI | Microsoft Learn
Error handling - Power Query | Microsoft Learn
If you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members encountering similar issues.
Should you have any further queries, please do not hesitate to contact the Microsoft Fabric community.
Thank you.