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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
Lorenza
New Member

Data Upload

Hello Team,

i am trying to upload data from query to power BI but encounter some errors each time. i dont know how to correct or move forward. 

Actually there are 200 bulky files in sharepoint that i tried to combine in query to upload in BI for Visuals, but the combining and uploading process is not going as expected. 

 

as the diagram shows, it turns like this for long but doesnt show or open in BI:

Lorenza_0-1780995625279.png

Lorenza_0-1780995694436.png

 

 

i need help please

Thanks

2 ACCEPTED SOLUTIONS
oussamahaimoud
Solution Sage
Solution Sage

Hi @Lorenza,

 

Power Query is trying to read one or more files as structured Excel workbooks (.xlsx) while their actual format is different, typically .csv, legacy .xls, corrupted files, or files whose extension doesn't match their real content.

 

Probably, the root cause is due to :

  • Mixed file types: some are .xlsx, others are .csv or .xls, but the combine function applies the same treatment to all of them
  • Corrupt or empty files within the batch
  • Locked/open files on SharePoint at the time of loading
  • "Transform Sample File" was built against one .xlsx but other files in the folder have a different format

So to resolve this issue, you can try this guideline step by step:

 

Step 1: Filter by extension before combining

In Power Query, before the combine step, add a filter on the Extension column:

= Table.SelectRows(Source, each [Extension] = ".xlsx")

This excludes .csv, .xls, and any unrelated file types from the folder.

 

Step 2: Exclude Office temporary files

SharePoint frequently generates ghost files prefixed with ~$. Add this filter as well:

= Table.SelectRows(Source, each not Text.StartsWith([Name], "~$"))

 

Step 3: Check the combine function

In the left queries panel, open "Transform Sample File" and confirm the source step uses:

Excel.Workbook([Content], true)

and not Csv.Document or anything else.

 

Step 4: Identify the problematic file

If the error still occurs, add a custom column to test each file individually and spot which one is breaking:

= try Excel.Workbook([Content], true) otherwise "ERROR"

This lets you pinpoint exactly which file(s) are causing the issue without blocking the entire query.

 

To sum up, the problem almost certainly comes from one or more files in your SharePoint folder that are not genuine .xlsx, which breaks the combine function. Filtering by extension and excluding temporary files resolves this in the vast majority of cases.


  Did my response help you? Clicking Kudos is a small gesture that goes a long way, it encourages contributors and helps the community thrive!


Did I answer your question? Please mark my post as a Solution, it helps others find the answer faster.


Senior Data & BI Consultant · Microsoft Fabric & Power BI Specialist


Connect with me on LinkedIn

View solution in original post

Step 1: Connect to the SharePoint Folder

In Power BI Desktop:

Get Data → SharePoint Folder (not SharePoint List)

Enter your root SharePoint URL only:

https://aroundtown.sharepoint.com/sites/GBL-M365-TQM

This loads a table listing all files in that site, including their binary content.

 

Step 2: Filter to Keep Only Your .xlsm Files

Once the table loads in Power Query, apply these filters immediately:

Filter by extension:

= Table.SelectRows(Source, each [Extension] = ".xlsm")

Exclude Office temp files:

= Table.SelectRows(#"Filtered Rows", each not Text.StartsWith([Name], "~$"))

Filter to your specific folder (if needed):

= Table.SelectRows(#"Filtered Rows1", each Text.Contains([Folder Path], "YOUR_FOLDER_NAME"))

 

Step 3: Do NOT Use the Default Combine Button

The "Combine Files" button Power Query suggests automatically uses Excel.Workbook() which doesn't work properly with .xlsm files in some configurations. Instead, add a custom column manually.

 

Step 4: Add a Custom Column to Extract the Sheet

Click Add Column → Custom Column and use:

= try Excel.Workbook([Content], true){[Item="YOUR_SHEET_NAME", Kind="Sheet"]}[Data] otherwise null

Replace YOUR_SHEET_NAME with the exact tab name that is identical across all 200 files.

If the sheet name varies, use index instead:

= try Excel.Workbook([Content], true){0}[Data] otherwise null

This takes the first sheet of each file regardless of its name.

 

Step 5: Expand the Tables

Once the custom column is created, click the expand icon (double arrows) at the top of that column → select the columns you need → uncheck "Use original column name as prefix" if you want clean headers.

 

Step 6: Promote Headers (if needed)

If the first row of each file contains the column headers, add:

= Table.TransformColumns(#"Expanded Column", {"YOUR_CUSTOM_COL", each Table.PromoteHeaders(_)})

Or use the "Use First Row as Headers" button after expanding.

 

Step 7: Remove Null Rows

After expanding, filter out rows where the custom column returned null (files that failed to parse):

= Table.SelectRows(#"Expanded Column", each [YOUR_CUSTOM_COL] <> null)

 

Step 8: Close & Apply

Once the preview looks correct → Close & Apply → your combined dataset is ready for visuals.

 

Remember that since your files are .xlsm (macro-enabled), make sure the sheet you're targeting contains data as a proper table or range, not just VBA output that only renders when macros run. Power Query reads the static data only, macros do not execute during import.


  Did my response help you? Clicking Kudos is a small gesture that goes a long way, it encourages contributors and helps the community thrive!


Did I answer your question? Please mark my post as a Solution, it helps others find the answer faster.


Senior Data & BI Consultant · Microsoft Fabric & Power BI Specialist


Connect with me on LinkedIn

View solution in original post

4 REPLIES 4
oussamahaimoud
Solution Sage
Solution Sage

Hi @Lorenza,

 

Power Query is trying to read one or more files as structured Excel workbooks (.xlsx) while their actual format is different, typically .csv, legacy .xls, corrupted files, or files whose extension doesn't match their real content.

 

Probably, the root cause is due to :

  • Mixed file types: some are .xlsx, others are .csv or .xls, but the combine function applies the same treatment to all of them
  • Corrupt or empty files within the batch
  • Locked/open files on SharePoint at the time of loading
  • "Transform Sample File" was built against one .xlsx but other files in the folder have a different format

So to resolve this issue, you can try this guideline step by step:

 

Step 1: Filter by extension before combining

In Power Query, before the combine step, add a filter on the Extension column:

= Table.SelectRows(Source, each [Extension] = ".xlsx")

This excludes .csv, .xls, and any unrelated file types from the folder.

 

Step 2: Exclude Office temporary files

SharePoint frequently generates ghost files prefixed with ~$. Add this filter as well:

= Table.SelectRows(Source, each not Text.StartsWith([Name], "~$"))

 

Step 3: Check the combine function

In the left queries panel, open "Transform Sample File" and confirm the source step uses:

Excel.Workbook([Content], true)

and not Csv.Document or anything else.

 

Step 4: Identify the problematic file

If the error still occurs, add a custom column to test each file individually and spot which one is breaking:

= try Excel.Workbook([Content], true) otherwise "ERROR"

This lets you pinpoint exactly which file(s) are causing the issue without blocking the entire query.

 

To sum up, the problem almost certainly comes from one or more files in your SharePoint folder that are not genuine .xlsx, which breaks the combine function. Filtering by extension and excluding temporary files resolves this in the vast majority of cases.


  Did my response help you? Clicking Kudos is a small gesture that goes a long way, it encourages contributors and helps the community thrive!


Did I answer your question? Please mark my post as a Solution, it helps others find the answer faster.


Senior Data & BI Consultant · Microsoft Fabric & Power BI Specialist


Connect with me on LinkedIn

Hi @oussamahaimoud ,

i tried solving with the solution you gave me but it isnt loading.

 

please can you help me with various steps for Uploading the files.

 

- the files are "xlsm" each stored in different sharepoint list but in the same folder. so after exactracting the foldername, i must extract each file from its sharepoint list then combine them in query to make a visual in BI. please help me with the various steps to combine these easily.  here are some screenshot to show my pathway:

 

Lorenza_0-1781005090527.png

 

after this step i usually combine the data immediately. how can i move forward please.

 

Thanks

Step 1: Connect to the SharePoint Folder

In Power BI Desktop:

Get Data → SharePoint Folder (not SharePoint List)

Enter your root SharePoint URL only:

https://aroundtown.sharepoint.com/sites/GBL-M365-TQM

This loads a table listing all files in that site, including their binary content.

 

Step 2: Filter to Keep Only Your .xlsm Files

Once the table loads in Power Query, apply these filters immediately:

Filter by extension:

= Table.SelectRows(Source, each [Extension] = ".xlsm")

Exclude Office temp files:

= Table.SelectRows(#"Filtered Rows", each not Text.StartsWith([Name], "~$"))

Filter to your specific folder (if needed):

= Table.SelectRows(#"Filtered Rows1", each Text.Contains([Folder Path], "YOUR_FOLDER_NAME"))

 

Step 3: Do NOT Use the Default Combine Button

The "Combine Files" button Power Query suggests automatically uses Excel.Workbook() which doesn't work properly with .xlsm files in some configurations. Instead, add a custom column manually.

 

Step 4: Add a Custom Column to Extract the Sheet

Click Add Column → Custom Column and use:

= try Excel.Workbook([Content], true){[Item="YOUR_SHEET_NAME", Kind="Sheet"]}[Data] otherwise null

Replace YOUR_SHEET_NAME with the exact tab name that is identical across all 200 files.

If the sheet name varies, use index instead:

= try Excel.Workbook([Content], true){0}[Data] otherwise null

This takes the first sheet of each file regardless of its name.

 

Step 5: Expand the Tables

Once the custom column is created, click the expand icon (double arrows) at the top of that column → select the columns you need → uncheck "Use original column name as prefix" if you want clean headers.

 

Step 6: Promote Headers (if needed)

If the first row of each file contains the column headers, add:

= Table.TransformColumns(#"Expanded Column", {"YOUR_CUSTOM_COL", each Table.PromoteHeaders(_)})

Or use the "Use First Row as Headers" button after expanding.

 

Step 7: Remove Null Rows

After expanding, filter out rows where the custom column returned null (files that failed to parse):

= Table.SelectRows(#"Expanded Column", each [YOUR_CUSTOM_COL] <> null)

 

Step 8: Close & Apply

Once the preview looks correct → Close & Apply → your combined dataset is ready for visuals.

 

Remember that since your files are .xlsm (macro-enabled), make sure the sheet you're targeting contains data as a proper table or range, not just VBA output that only renders when macros run. Power Query reads the static data only, macros do not execute during import.


  Did my response help you? Clicking Kudos is a small gesture that goes a long way, it encourages contributors and helps the community thrive!


Did I answer your question? Please mark my post as a Solution, it helps others find the answer faster.


Senior Data & BI Consultant · Microsoft Fabric & Power BI Specialist


Connect with me on LinkedIn

Thanks so much. 

 

i'm grateful!

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.