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
Fcoatis
Post Patron
Post Patron

Power Query extract specific sheets of the same Excel Workbook

Hello community,

 

Is there a way to use Power Query to extract only data from the same workbook where all the sheets  names  begin with "rec_" for instance?

 

Thanks in advance

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community Champion

Sure:

 

let
    Source = Excel.Workbook(File.Contents("<YourPathAndFileName"), null, true),
    #"Filtered Rows" = Table.SelectRows(Source, each [Kind] = "Sheet" and Text.StartsWith([Item], "rec_"))
in
    #"Filtered Rows"
Specializing in Power Query Formula Language (M)

View solution in original post

3 REPLIES 3
MarcelBeug
Community Champion
Community Champion

Sure:

 

let
    Source = Excel.Workbook(File.Contents("<YourPathAndFileName"), null, true),
    #"Filtered Rows" = Table.SelectRows(Source, each [Kind] = "Sheet" and Text.StartsWith([Item], "rec_"))
in
    #"Filtered Rows"
Specializing in Power Query Formula Language (M)

Hello,

 

I find that this does not work if the file lives in a OneDrive folder synced to the PC. I works fine with the path

 

= Excel.Workbook(File.Contents("C:\stuff\Book1.xlsx"), null, true)

 

but with the path C:\Users\user\OneDrive\Forums\filename.xlsx it throws an error "The process cannot access the file because it is being used by another process."

 

OneDriveQuery.png

 

How can it be made to work for OneDrive stored files?

Thank you

 

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