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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
OZMckenzie
Helper I
Helper I

How to extact the product name from Excel worksheet tab?

Hello,

 

I have a Excel workbook of  inspection data for multiple products. I'd like to do "Append" in Power Query to combine these sheets. However, the product name is not included in the datasheet, but on the tab. Please see the attached pic:

 

tab Capture.PNG

 
 

I'd like to add the product name in each worksheet, so I can identify the product name after appending these sheets. Please advise how to capture the name on the tab and add into sheets?

 

Thanks in advance!

2 REPLIES 2
AlB
Super User
Super User

Hi @OZMckenzie 

Try this:

let
    Source = Excel.Workbook(File.Contents(Your_File_Path), null, true),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Table.AddColumn([Data], "SheetName", (outer)=> [Name]))
in
    #"Added Custom"

with Your_File_Path a parameter containing the path to your file. The first step will yield something like this:

test.jpg

Then the second step adds a new column to the tables in [Data] (contents of each sheet or table) with the name of the Sheet. In the column Kind you can see the type of each item.

Please mark the question solved when done and consider giving kudos if posts are helpful.

 Cheers 

SU18_powerbi_badge

 

Hello @AlB ,

 

Thank you very much for advice!

 

I'm new to Power Query. Here is what I tried:

Loading one sheet from the workbook.

Click the "source" in the applied steps to get the same view as your screenshot.

 

Do you mean to add a custom column with the formula?

Query Capture - Copy.PNG

 

 

 

 

 

 

 

I found another way to populate the product name in datasheets, but not sure if this is the correct way:

Removing other columns, leave only product name and data, and expand the data. All sheets in this workbook are then stacked and also have the product names in the first column.

 

 Query cature 2.PNG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors