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
fbittencourt
Advocate II
Advocate II

Tab name change dynamically updated

Hi All !!

 

Everytime that my excel file tab names changes I need to update manually, is there way to update automatically on power query?

 

Like if my tab changes name from 3 to 4

 

Sample pbi :

let
Source = Excel.Workbook(File.Contents("C:\Users\h22012\OneDrive - BNP Paribas\Customers.xlsx"), null, true),
#"Filtered Rows" = Table.SelectRows(Source, each ([Name] = "1" or [Name] = "2" or [Name] = "3")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Name", "Data"}),
#"Expanded Data" = Table.ExpandTableColumn(#"Removed Other Columns", "Data", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12", "Column13", "Column14", "Column15", "Column16", "Column17"}, {"Data.Column1", "Data.Column2", "Data.Column3", "Data.Column4", "Data.Column5", "Data.Column6", "Data.Column7", "Data.Column8", "Data.Column9", "Data.Column10", "Data.Column11", "Data.Column12", "Data.Column13", "Data.Column14", "Data.Column15", "Data.Column16", "Data.Column17"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Data",{"Data.Column9", "Data.Column10", "Data.Column11", "Data.Column12", "Data.Column13", "Data.Column14", "Data.Column15", "Data.Column16", "Data.Column17"}),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Columns", [PromoteAllScalars=true]),
#"Renamed Columns" = Table.RenameColumns(#"Promoted Headers",{{"1", "Tab name"}})
in
#"Renamed Columns"

 

Tks in advance!!!

1 ACCEPTED SOLUTION
Zanqueta
Impactful Individual
Impactful Individual

Hi @fbittencourt.

Yes, Power Query allows you to automatically load all sheets from an Excel file, even if you don’t know their names in advance.

🛠️ Power Query code to load all sheets

let
Source = Excel.Workbook(File.Contents("C:\Users\h22012\OneDrive - BNP Paribas\Customers.xlsx"), null, true),

// Keep only sheets (ignore named ranges and tables)
OnlySheets = Table.SelectRows(Source, each [Kind] = "Sheet"),

// Select relevant columns
SelectedSheets = Table.SelectColumns(OnlySheets, {"Name", "Data"}),

// Promote headers and combine all sheets
CombinedData = Table.Combine(
List.Transform(SelectedSheets[Data], each Table.PromoteHeaders(_))
)
in
CombinedData
📌 Explanation
Excel.Workbook(...): loads all elements from the Excel file (sheets, tables, named ranges).
Table.SelectRows(..., each [Kind] = "Sheet"): filters only the sheets.
List.Transform(..., each Table.PromoteHeaders(_)): promotes headers for each sheet.
Table.Combine(...): merges all sheets into a single table.
🔁 Optional: Keep sheet name as a column
If you want to track which sheet each row came from, you can add the sheet name before combining:


SheetsWithName = List.Transform(OnlySheets, each Table.AddColumn(Table.PromoteHeaders([Data]), "SheetName", each [Name]))
CombinedData = Table.Combine(SheetsWithName)
⚠️ Important Notes
All sheets should have the same structure (same columns), otherwise Table.Combine may produce errors or nulls.
If structures vary, you may need to standardize them before combining.
If this solved your issue, please mark it as the accepted answer to help others in the community.

View solution in original post

7 REPLIES 7
Zanqueta
Impactful Individual
Impactful Individual

Hi @fbittencourt.

Yes, Power Query allows you to automatically load all sheets from an Excel file, even if you don’t know their names in advance.

🛠️ Power Query code to load all sheets

let
Source = Excel.Workbook(File.Contents("C:\Users\h22012\OneDrive - BNP Paribas\Customers.xlsx"), null, true),

// Keep only sheets (ignore named ranges and tables)
OnlySheets = Table.SelectRows(Source, each [Kind] = "Sheet"),

// Select relevant columns
SelectedSheets = Table.SelectColumns(OnlySheets, {"Name", "Data"}),

// Promote headers and combine all sheets
CombinedData = Table.Combine(
List.Transform(SelectedSheets[Data], each Table.PromoteHeaders(_))
)
in
CombinedData
📌 Explanation
Excel.Workbook(...): loads all elements from the Excel file (sheets, tables, named ranges).
Table.SelectRows(..., each [Kind] = "Sheet"): filters only the sheets.
List.Transform(..., each Table.PromoteHeaders(_)): promotes headers for each sheet.
Table.Combine(...): merges all sheets into a single table.
🔁 Optional: Keep sheet name as a column
If you want to track which sheet each row came from, you can add the sheet name before combining:


SheetsWithName = List.Transform(OnlySheets, each Table.AddColumn(Table.PromoteHeaders([Data]), "SheetName", each [Name]))
CombinedData = Table.Combine(SheetsWithName)
⚠️ Important Notes
All sheets should have the same structure (same columns), otherwise Table.Combine may produce errors or nulls.
If structures vary, you may need to standardize them before combining.
If this solved your issue, please mark it as the accepted answer to help others in the community.

Sorry to bother you, if you can help me I appreciate ,but I have an error when I add to keep the sheet name

 

fbittencourt_0-1762850441724.png

 

Tks!!

 

lbendlin
Super User
Super User

You can select rows by index rather than by a name search.  

 

Ideally your data source should not change in the way you describe.

I agree with you, but the tabs are related to periods ( last 6 months) , after the update it changes the name like ( last 9 months) , so pbi do not recognise automatically...

Define a way to sort the tab names descending and then grab the first item {0}

parry2k
Super User
Super User

@fbittencourt is there always a one sheet in the Excel file?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi Parry,

 

We have only one excel file with many period tabs, the person update the tabs concerning the period of the analysis, like tab last 6 months after update changes the name last 9 months, and power bi do not recognise, the option is to change on advance editor or import again with the new name, I need to know if there´s a way to change automatically, maybe on power automate. tks again!!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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