Add named range from individual files to Folder source in Power Query

cb366374

Board Regular
Joined
Feb 25, 2012
Messages
95
I have a folder of files that I am querying for the files' date modified, file size, and a few other attributes. Long-story-short we have multiple versions of these files in subfolders and each "release" we make a new folder and copy the Excel files into them. So I created this query that can track which files are different from version to version (it's basically a versioning tool). However, my issue is there are more granular version numbers stored in a named range within each file that I would like to access. The cell is named the same in every file (let's called it "VersionCell"). So what I'm trying to do is add the contents of this cell to the table as a new column/attribute.

Already Exists.........Need this one added
FileNameDate ModifiedDate CreatedFull PathVersionNum
File110/31/201610/31/2016C:\\Version10\File110.1
File210/29/201610/29/2016C:\\Version11\File211.0

<tbody>
</tbody>

The files are rather large so I'm not sure if it's possible to fit this in the same query (or if it's even possible for smaller files). The only experience I have with this type of query was super simple...
Code:
let    Source = Excel.CurrentWorkbook(){[Name="ThirdRange"]}[Content],
    ThisCell = Source{0}[Column1]
in
    ThisCell

This seems like one of those things that has to be possible but I can't figure it out. I'm fairly new to Power Query so if someone can point me to a helpful resource, that would help also. Thanks in advance!

Also, here is the current query. I stripped a bunch of stuff out to make it simpler to view. Just a basic folder query but you can see where I remove the content column that stores the file.
Code:
let    Source = Folder.Files("path goes here"),
    #"Removed Columns" = Table.RemoveColumns(Source,{"Content"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([Extension] = ".xlsx")),
    #"Expanded Attributes" = Table.ExpandRecordColumn(#"Filtered Rows", "Attributes", {"Archive", "Compressed", "Content Type"}, {"Attributes.Archive", "Attributes.Compressed", "Attributes.Content Type"})
in
    #"Expanded Attributes"
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi cb,
Add this step after your last one.
Code:
 #"Added Custom" = Table.AddColumn(#"Expanded Attributes", "Version", each Excel.Workbook([Content]){[Name = "VersionCell"]}[Data]{0}[Column1])

Regards
 
Upvote 0
That's great, thank you!

It didn't work at first because I was removing the content column. I moved that step to the end and it works. However, it still makes the query very slow. I sped it up some by breaking it into multiple queries and only pointing to the subfolders I need but it still takes about a minute to update. Any idea on how to speed that up?
 
Upvote 0
Basically, is there a way to do this without loading the entire file like it appears to be doing now?
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,553
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top