• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Combine excel sheets from multiple workbooks in Power BI|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Combine excel sheets from multiple workbooks in Power BI|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryCombine excel sheets from multiple …
sp_PrintTopic sp_TopicIcon
Combine excel sheets from multiple workbooks in Power BI
Avatar
Premchand Balachandar

New Member
Members
Level 0
Forum Posts: 2
Member Since:
June 22, 2019
sp_UserOfflineSmall Offline
1
June 22, 2019 - 5:34 am
sp_Permalink sp_Print sp_EditHistory

My requirement is, I need to combine excel sheets from multiple workbooks using Power BI.

Folders structure is like this Jan, Feb, Mar, April are the folder name, which consists of workbook name as Jan1, Jan12, Jan15, Feb1, Feb12 and so on and type 1, type 2 and type 3 are the sheet name in each workbook.

I would like to combine all type 1 sheet from Jan, Feb, Mar folder and I need to write an M function to repeat the process for all other types (i.e type 2 and type 3).

Could you please help me on this requirement using Power Query?

So far I tried to create the below function to get the data from folder after that, I do manual steps to combine the data from workbooks.

 

(filepath)=> let Source = Folder.Files(filepath), #"Filtered Rows1" = Table.SelectRows(Source, each not Text.StartsWith([Name], "~$")), #"Filtered Hidden Files1" = Table.SelectRows(#"Filtered Rows1", each [Attributes]?[Hidden]? <> true), #"Reordered Columns" = Table.ReorderColumns(#"Filtered Hidden Files1",{"Name", "Content", "Extension", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path", "Source Type"}), #"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"Extension", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path", "Source Type"}) in #"Removed Columns"
Avatar
Premchand Balachandar

New Member
Members
Level 0
Forum Posts: 2
Member Since:
June 22, 2019
sp_UserOfflineSmall Offline
2
June 23, 2019 - 10:32 pm
sp_Permalink sp_Print

Finally, I got the solution, added below

let
Source = Folder.Files("C:/temp"),
#"Added Workbook" = Table.AddColumn(Source, "Workbook", each Excel.Workbook([Content], null, true)),
#"Added Sheet" = Table.AddColumn(#"Added Workbook", "Sheet", each Table.PromoteHeaders( [Workbook]{[Item="Aug Data",Kind="Sheet"]}[Data] , [PromoteAllScalars=true]) ),
#"Filtered Rows2" = Table.SelectRows(#"Added Sheet", each ([Extension] = ".xlsx")),
#"Filtered Rows3" = Table.SelectRows(#"Filtered Rows2", each not Text.StartsWith([Name], "~$")),
#"Filtered Rows4" = Table.SelectRows(#"Filtered Rows3", each ([Folder Path] = "C:/temp")),
#"Renamed Columns" = Table.RenameColumns(#"Filtered Rows4",{{"Name", "Source"}}),
#"Filtered Hidden Files1" = Table.SelectRows(#"Renamed Columns", each [Attributes]?[Hidden]? <> true),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Hidden Files1",{"Source", "Sheet"}),
#"Filtered Rows" = Table.SelectRows(#"Removed Other Columns", each Text.EndsWith([Source], "xlsx")),
#"Expanded Tables" = Table.ExpandTableColumn( #"Filtered Rows" , "Sheet", Table.ColumnNames( #"Filtered Rows"[Sheet]{0} ) ),
#"Filtered Rows1" = Table.SelectRows(#"Expanded Tables", each ([Chain] <> null)),
#"Filtered Rows5" = Table.SelectRows(#"Filtered Rows1", each [Postcode] <> null)
in
#"Filtered Rows5"

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Velouria, Lionel Baijot, Jack Brett, Ben Hughes, Ivica Cvetkovski
Guest(s) 12
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Hayden Hao
Angela chen
Sean Moore
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Forum Stats:
Groups: 3
Forums: 24
Topics: 6211
Posts: 27239

 

Member Stats:
Guest Posters: 49
Members: 31891
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.