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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Draginko
Helper I
Helper I

M code syntax for connecting to Excel files - difference between sheet and table (Navigator step)

Hey all,

I have a quite weird question - is there somewhere some documentation, blog, video, or anything explaining M code for connecting to excel? Especially if you want to modify the code for switching between table in excel file and sheet as a whole? (Basically covering "Navigator" step in UI).

I am really struggling with this for quite some time, and every time I am googlig like hell to find some explanation, and in the end I will end up with creating new query with new connection.

The reason is, that we are predominantly using excel files as a data source, many times those excel files are outcome of some excel-based power query scripts. Unfortunatelly we are often changing many dataflow processes, especially for new projects, and result is that sometimes the data are in shape of a table (in case of PQ outputs) and sometimes just a sheet (exports from other systems). This wouldnt be a big deal, with the exception of getting this expression error (details can vary, based on file or my unsuccessful amendment of the code):Capture1.JPGAs our files are huge and we have a lot of queries, every refresh or preview takes dozens of minutes, sometimes even hour, I prefer to do all the changes via m code, so I can avoid unintentional waiting on preview for change to take effect. Also, it would be easier just to modify the code, instead of e.g. transforming sheet to table in the source file (from time perspective). However I am not able to grasp this little piece of code, how to modify it properly so it will work, based on my requirements, for instance this code: 
Capture2.JPG

 




This code should work, as the file I am connecting is just a sheet, with name Sheet1, without any table, and it is still not working. For different file, also sheet, is it working flawlessly.

So, any idea, or advice how to grasp this small topic? Or am I missing something? Everything is welcomed 🙂
PS: sorry for maybe a wider context than necessary

1 ACCEPTED SOLUTION
1 REPLY 1

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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