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
roni1986
New Member

How to combine tabs with differents names from many workbooks?

Hello,

 

Today I have 2 workbooks files in the folder "C:\Users\User\Downloads\Teste Power Query" with this pattern names: "FY## Arquivo.xlsx", where ## is the last two digits form current year of the file. In theses files I have a tab with this pattern name "FY## aba", where ## is the last two digits form current year of the file.


In the same folder, I have others workbooks files that doesn't related and every new year a new workbook file is created with the name pattern and tab name pattern above.

 

I need combine the two tabs, and every year automatcily combine the tab from the new file, but I don't know how to combine with the differents names from the tabs.

 

I managed to filter the workbooks using start with and contais, but I don't find any way to do this with the tabs.

PS: In theses workbooks there more tabs, but I only need to combine that with pattern name.

2 ACCEPTED SOLUTIONS
m_dekorte
Super User
Super User

Hi @roni1986,

 

See if this method is helpful. Although this illustrates how it works with excel tables, the same can be achieved with sheets. If you need further assistance, supply some dummy data.

Step by Step Guide to combine tables from files in a folder. 

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

View solution in original post

Anonymous
Not applicable

Hi @roni1986 ,

 

Please try the below codesL

let
    Source = Folder.Files("C:\\Users\\User\\Downloads\\Teste Power Query"),
    FilteredFiles = Table.SelectRows(Source, each Text.StartsWith([Name], "FY") and Text.EndsWith([Name], "Arquivo.xlsx")),
    TransformFiles = Table.AddColumn(FilteredFiles, "Transformed", each Excel.Workbook([Content])),
    ExpandTables = Table.ExpandTableColumn(TransformFiles, "Transformed", {"Name", "Data"}),
    FilteredTabs = Table.SelectRows(ExpandTables, each Text.StartsWith([Name], "FY") and Text.EndsWith([Name], "aba")),
    CombinedData = Table.Combine(FilteredTabs[Data])
in
    CombinedData

If the above doesn't work, please provide more details.

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @roni1986 ,

 

Please try the below codesL

let
    Source = Folder.Files("C:\\Users\\User\\Downloads\\Teste Power Query"),
    FilteredFiles = Table.SelectRows(Source, each Text.StartsWith([Name], "FY") and Text.EndsWith([Name], "Arquivo.xlsx")),
    TransformFiles = Table.AddColumn(FilteredFiles, "Transformed", each Excel.Workbook([Content])),
    ExpandTables = Table.ExpandTableColumn(TransformFiles, "Transformed", {"Name", "Data"}),
    FilteredTabs = Table.SelectRows(ExpandTables, each Text.StartsWith([Name], "FY") and Text.EndsWith([Name], "aba")),
    CombinedData = Table.Combine(FilteredTabs[Data])
in
    CombinedData

If the above doesn't work, please provide more details.

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

Hello, stoped in this line:

 

ExpandTables = Table.ExpandTableColumn(TransformFiles, "Transformed", {"Name", "Data"}),

 

Expression.Error: O campo 'Name' já existe no registro.
Detalhes:
Name=Name
Value=

 

I Change the "Name" to "Item" (my Excel is in Portuguese), and that worked.

 

 

m_dekorte
Super User
Super User

Hi @roni1986,

 

See if this method is helpful. Although this illustrates how it works with excel tables, the same can be achieved with sheets. If you need further assistance, supply some dummy data.

Step by Step Guide to combine tables from files in a folder. 

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

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