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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
webportal
Impactful Individual
Impactful Individual

Power query function to expand the first table of a workbook

I have a bunch of Excel workbooks with a table in them.

Some tables have the name "Table1", while some others have another name.

 

Power Query built a function like:

let
    Source = (Parameter1) => let
        Source = Excel.Workbook(Parameter1, null, true),
        Table1_Table = Source{[Item="Table1",Kind="Table"]}[Data]
    in
        Table1_Table
in
    Source

 

Which is breaking in the cases where the table has a different name.

 

How do I adapt this code to get the first table it finds within the workbook irrespective of the name?

 

Thanks!

 

 

1 ACCEPTED SOLUTION

let
    Source = (Parameter1) => let
        Source = Excel.Workbook(Parameter1, null, true),
        Table1_Table = Table.SelectRows(Source, each ([Kind] = "Table"))[Data]{0}
    in
        Table1_Table
in
    Source

View solution in original post

5 REPLIES 5
webportal
Impactful Individual
Impactful Individual

@AlienSxthat's it, thank you!

CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1679927074953.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

webportal
Impactful Individual
Impactful Individual

@AlienSxthanks for helping!

The Excel object contains multiple objects, like sheets, named ranges and tables.

By 1st table, I mean, whatever name it is, I want the first it finds, because I know that each file contains only one.

let
    Source = (Parameter1) => let
        Source = Excel.Workbook(Parameter1, null, true),
        Table1_Table = Table.SelectRows(Source, each ([Kind] = "Table"))[Data]{0}
    in
        Table1_Table
in
    Source
AlienSx
Super User
Super User

Hello, @webportal what is "first table"? Run 

Excel.Workbook(Parameter1, null, true)

with some Parameter1 value. You get the list of items in that workbook. Okay, filter "Kind" column to get tables only. How do pick "first" table? What is it? 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Kudoed Authors