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
k-k-k-k
Frequent Visitor

Power Query M , multiple sheet combine, add sheet name as new column to each corresponding table

hi experts,

 

i have action is combine 10+ sheet table in one Excel, the sheet name is contain "year" info, like the sheet name is "2018". but in the table of sheet is not have year column.   so i need extract the sheet name to table's column.  i know there expand table will keep the sheet name for every sheet table, BUT ,  there's some special reason, i need add the column first  for every table before expand. 

I think there should  some M function or expression can do, but i have no idea. could yo help me ?   thank you very much!

kkkk_0-1637638226405.png

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

NewStep=#table(Table.ColumnNames(PreviousStepName),Table.ToList(PreviousStepName,each {_{0},Table.AddColumn(_{1},"Year",(x)=>_{0})}))

View solution in original post

2 REPLIES 2
k-k-k-k
Frequent Visitor

Hi daniel,  the expression is works well, it solve my problem.  thank you very much!  u are so powerful .

wdx223_Daniel
Super User
Super User

NewStep=#table(Table.ColumnNames(PreviousStepName),Table.ToList(PreviousStepName,each {_{0},Table.AddColumn(_{1},"Year",(x)=>_{0})}))

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