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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Get sheet in the first order(most left sheet) no matthe what its name is

Hi,

 

What M code can we get sheet in the first order(most left sheet) no matthe what its name is?

Sheet name is dynamic so I shouldn't type in the code. 

 

e.g. for this snapshot, it will be TOSS Serivce PO_Master cuz it is the most left(first)

 

jeongkim_0-1732689103531.png

 

1 ACCEPTED SOLUTION

Hi @Anonymous  Try this way:

 

 

let
    Source = Excel.Workbook(File.Contents("YourFilePath.xlsx"), null, true),
    FirstSheet = Source{0}[Data]
in
    FirstSheet

 

 

 

Just replace "YourFilePath.xlsx" with the path to your Excel file. This will dynamically get the data from the first sheet, no matter what its name is.

 

Also, your mentioned method would work.

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

I've tested as below and it seems it will stack in initial order unless put other filter to affect. 

Then I can just take first row in Query. 

If it is not correct pls guide me. 

 

jeongkim_0-1732690419871.png

 

jeongkim_1-1732690431126.png

 

 

 

jeongkim_2-1732690551460.png

 

Hi @Anonymous  Try this way:

 

 

let
    Source = Excel.Workbook(File.Contents("YourFilePath.xlsx"), null, true),
    FirstSheet = Source{0}[Data]
in
    FirstSheet

 

 

 

Just replace "YourFilePath.xlsx" with the path to your Excel file. This will dynamically get the data from the first sheet, no matter what its name is.

 

Also, your mentioned method would work.

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.