Forum Discussion

poinfrettia's avatar
poinfrettia
Frequent Visitor
1 year ago
Solved

Excel import not consistently recognising blank first column

Hi there, I have a Gen 2 Flow which imports lots of identical excel workbooks in a folder. Column A in all of them is blank - but I'm getting errors as sometimes the Gen 2 Flow imports this first blank column, and sometimes skips it.

 

I understand this is based on excels 'used range' default. Can I force the import to start in column A somehow? Or define the specific range? 

  • Thanks - I tried setting InferSheetDimensions to false but you're right it still uses excel's used range. I don't have control over the file creation unfortunately but I can interfere if a file is recieved and breaks the flow. A bit faffy - hopefully a feature to control the import is added soon. Thanks! 

10 Replies

  • miguel's avatar
    miguel
    Community Admin

    Could you please share the M code that you're using? You can get it by going into the "Advanced editor" of your query in the "View" tab. If you're using a function to drive the logic, please share that custom function as well

    • poinfrettia's avatar
      poinfrettia
      Frequent Visitor

      Hi Miguel and thanks for replying - it's actually the very first step, i.e. let Source = Excel.Workbook(Parameter, null, true), Navigation = Source{[Item = "Sheet1", Kind = "Sheet"]}[Data].

       

      When the Gen 2 Flow imports the spreadsheet, it automatically determines which column (A or B in this case) should be "Column1" based on what Excel indicates is the 'used range' on the sheet. If column A is blank, usually it decides column B should be Column1. The problem I'm having is that for some sheets, even though column A is blank in all of them, it's setting column A as Column1 in some files and column B in others.

       

       
      • Ehren's avatar
        Ehren
        Microsoft Employee

        The two files likely have different "used range" dimensions. There are instructions for how to inspect the dimensions here:

        https://learn.microsoft.com/en-us/power-query/connectors/excel#how-to-diagnose-incorrect-dimensions

         

        If you control the creation of the files, you may be able to remedy this by clearing any formatting/values/etc. from the first column. Even though the cells are blank, there may be some formatting or other metadata that's causing them to be included in the dimensions.

         

        Alternatively, you could edit the first column in all the files to include something (even just a space) so that they're all consistent in having the real data start in Column2.

         

        You could also try using the InferSheetDimensions option of Excel.Workbook. I don't recall if it will ignore leading null cells, but it would be worth a try.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi poinfrettia ,

     

    Thank you for reaching out to Microsoft Fabric Community Forum.

    miguel Thank you for your quick response.

     

    poinfrettia Yes, you're  right. Could you please try the below M code after

    We can explicitly define the range of data in Advanced Editor in View tab.

     

    After the Navigation step in M code, you can define the columns as below:

     #"Selected Columns" = Table.SelectColumns(#"Navigation 1", {"Column1", "Column2"}),  // Replace with actual column names

     

    If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos " – I’d truly appreciate it!

     

    Regards,

    B Manikanteswara Reddy

    • poinfrettia's avatar
      poinfrettia
      Frequent Visitor

      Hi and thanks for replying - I've added more details to Miguel's reply which will hopefully clarify the problem better.