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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.