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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

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
Super User
Super User

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.

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn

View solution in original post

7 REPLIES 7
Zanqueta
Super User
Super User

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.

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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