Forum Discussion

RyanW86's avatar
RyanW86
Regular Visitor
1 month ago
Solved

Change to the way Power Query reads Excel files?

My colleagues and I have just this week encountered a problem reading and refreshing Excel files in both the service and Power BI Desktop. For context, the Excel files are stored in SharePoint; we have tried SharePoint.Files, Web.Content, Excel.Workbook and keep running into the same problem where it appears that Power Query is faithfully reproducing the data but when attempting to load into Desktop or refresh in the service, we are getting either a "data has been corrupted" type of error or "the key didn't match any rows in the table" type of error, but the files were refreshing with the same Excel documents just the day before. Nothing has changed in the location, names or content of the Excel files in question, we just suddenly can't refresh them. For additional context, we stay one month behind the Power BI Desktop updates for the sake of avoiding bugs to whatever extent we can; we are currently working on  2.155.756.0 64-bit (June 2026) though I realise that makes no difference to service-side refreshes. Any advice would be appreciated.

  • RyanW86's avatar
    RyanW86
    1 month ago

    Hi There,

    It turns out that the software we use to apply Sensitivity labels is affecting Excel metadata, rendering it corrupt from Power Query's point of view. As such, we have elected to transition away from using Excel files and will switch to CSV files.

    Thanks.

11 Replies

  • Hi RyanW86 

    The “data has been corrupted” message is often not literal file corruption. In Power Query, it can mean the binary stream or workbook structure isn’t what the connector expected.

    However do look out for the below pointers that may have caused this issue:

    If you’re combining multiple Excel files from SharePoint, a single bad workbook can cause the whole refresh to fail. Common culprits:

    • a hidden temp file accidentally included
    • a workbook that opens with a repair message in Excel
    • a file with a broken table object
    • a workbook saved while still open/locked

    Sometimes the SharePoint.Files / Web.Contents pattern breaks because of:

    • site URL changes at the tenant level
    • authentication token/session weirdness
    • connector cache mismatch
    • a library or file version that Power Query can see in Desktop but the service resolves differently
  • RyanW86 

    The error you are encountering "The key didn't match any rows in the table"    means the file name is changed and you are source path is harcoded in Power Query.

    So you need to follow these steps and hopefully you will not encounter this problem again.

    1-Check Sheet and Table Names

    Open your Excel file and look at the names of your sheets or tables. Power BI looks for the exact same names every time. If a sheet name changed (for example, from "Sheet1" to "Data"), change it back, or update the name in your Power BI steps.

    2-Pick the First Sheet Automatically

    If you are putting together many different files and the sheets inside them have different names, Power BI gets disorganized. You can change your Power Query steps to always pick the very first sheet of any file, no matter what it is named.

    3-Check the Column Headers

    Look at the titles at the top of your Excel columns. They must be exactly the same as before. If a column title is misplaced, spelled differently, or has extra spaces, Power BI will stop working and show an error.


    If this helps, ✓ Mark as Kudos | Help Others

  • Thanks for sharing the update. Changes to how Power Query interprets Excel files can have a real impact on existing queries, especially when workbooks rely on consistent sheet names, ranges, or inferred data types. One thing I've found helpful is making the import steps as explicit as possible—for example, selecting named tables instead of entire worksheets and setting column data types manually rather than relying on automatic detection. That tends to make queries more resilient when the underlying connector behavior changes in future updates.

  • RyanW86's avatar
    RyanW86
    Regular Visitor

    Hi All,

     

    Thank you for the feedback.

    What is concerning me here is that there have been no changes to file, sheet or field names at all. In some cases, we are ingesting multiple excel files that all have a common name part, in other cases they are single files with multiple sheets, and in an isolated case it is a single file with a single sheet. Even locations have not changed.

    I will test to see if being more explicit about field names and data types helps, but I feel a little dubious in the sense that we see everything we expect to see in Power Query - row counts, field names, data types all line up with what we see in the actual files.

    To the best of our knowledge there have been no changes to the site name or authentication requirements.

    • v-saisrao-msft's avatar
      v-saisrao-msft
      Icon for Community Support rankCommunity Support

      Hi RyanW86,

      Thank you powerbidev123 Murtaza_Ghafoor jason533, for your insights.

      Since the workbook previews correctly in Power Query, I'd recommend identifying which Applied Step first fails during Close & Apply, as Microsoft recommends reviewing the query steps to pinpoint refresh errors. Also, re-save one of the affected workbooks in Excel to refresh workbook metadata, and if you're using Excel.Workbook, try enabling InferSheetDimensions=true, which Microsoft recommends for workbook dimension inconsistencies. Ensure the workbook isn't open or locked during refresh, as this can prevent Power Query from accessing the file.

      Power Query Excel connector - Power Query | Microsoft Learn

      Handling data source errors (Power Query) | Microsoft Support

       

      Thank you.

      • RyanW86's avatar
        RyanW86
        Regular Visitor

        Thank you.

        I'm afraid we've tried these suggestions and while we have been able to get some of our files back to refreshing, there is still one scenario we can't quite work out.

        We have a need to analyse multiple weekly excel exports in the same report. These Excel exports are stored in SharePoint (same folder - no changes). They are exported from a source system and settings have been consistent throughout. We ingest data from around 50 excel docs all structured identically and named consistently. 

        Where previously we were able to refresh this model without any trouble, this one also stopped working at the same time as all of this excel strangeness began (7 July). We've tried open and closing the workbooks, resaving them, restructuring our Power Query - pretty much everything we can think of. The problem I am finding is when we go through the navigation steps in Power Query, some of the files (when looking at them one-by-one) return the columns you'd expect - [Name], [Item], [Kind], [Hidden], but other files in the list are only returning [Name] and [Data]. 

        When we try to process the whole lot of them, we are now consistently getting the message "DataFormat.Error: We were unable to load this Excel file because we couldn't understand its format. File contains corrupted data." However, each of the files, when opened individually, seems to work.

        Again, I want to make it clear, that this whole process was working for well over a year and just stopped working earlier this month. Now this particular model appears to refresh in Desktop but will not refresh in the service. Again, for additional context, going through applied steps in the service, everything appears to work, but when I select the dropdown in the column that shows the file names, once the whole query has processed, it is there that I get the corrupted data message.