Want2BExcel
Board Regular
- Joined
- Nov 24, 2021
- Messages
- 114
- Office Version
- 2016
- Platform
- Windows
So I found this video about the use of named ranges to make a Power Query dynamic file path and I thought this looks like a great idea. Easy to make a macro to a button in the worksheet, guiding users to point at their personal folder, where ever they want that. Thereby creating a folder path in a cell that Power Query then can use as reference to update the path for it's datasource. In this case the datasource (user's folder) holds the .csv files need to make the entire workbook perform as it was intended to begin with. The folder gets loaded with more and more files as times go by and even though the user probably don't change this when first set, the problem lye in every user needs to do this once so that Power Query knows where to look for the .csv files. This can be a bit complicated to explain to a user, without them going
Forgive me if I don't use the right terms. I'm really new to power query and all it's beauty.
So even though this video (and everything else on this matter I've read) is about showing a path to a file, I thought that it could be used to my task, show a path to the folder (that holds the files). In a standard query>from file>from folder, I don't need to give file names. I just point to the folder, set up the query and every time i put in a new csv file, it automatically reads the new file. So I figured, hey, just point to the folder with this new approach an all the files is then also found...but I think there is something I don't take in consideration. Something is behaving strangely
In the advanced editor I've changed this according to instructions:
to this (GetFolder is the named range cell that gets the folder path from the users button-click)
And well it kind of works.... When I set it up it works perfectly. But when performing a test run I noticed it wasn't working at all.
As mentioned, I use GetFolder as my named range. When the content of GetFolder changes value (a new folder path) , Power Query don't register it....not even if I update all. The DataSource don't update to the new value at all...weirdest part is, if I open advanced editor and just briefly change GetFolder to Getfolder2 in FilePath = Excel.CurrentWorkbook(){[Name="[B]GetFolder[/B]"]}[Content]{0}[Column1] I, of course get an error at first, but THEN when I the change it back to GetFolder, the new value is now registered. What, Why Pfft!? Why can't it just do that initiarially...it's the same line! I really don't understand. It's like the Query can't update it's data source value automatic. It can "read" GetFolder just fine or else I would get an error, so why the h... don't it update automatically It kind of ruins the whole purpose of doing this if it doesn't help the user. It's really not a bonus if I have to explain to users, that they just have do open this and this and enter advance editor and just change the Name="GetFolder" briefly and then back. It's REALLY annoying!!!! Can anybody pleeeeease explain this for me?
Forgive me if I don't use the right terms. I'm really new to power query and all it's beauty.
So even though this video (and everything else on this matter I've read) is about showing a path to a file, I thought that it could be used to my task, show a path to the folder (that holds the files). In a standard query>from file>from folder, I don't need to give file names. I just point to the folder, set up the query and every time i put in a new csv file, it automatically reads the new file. So I figured, hey, just point to the folder with this new approach an all the files is then also found...but I think there is something I don't take in consideration. Something is behaving strangely
In the advanced editor I've changed this according to instructions:
Power Query:
Source = Folder.Files("C:\Users\Want2BeExcel\Documents\TEST\DATA"),
Power Query:
FilePath = Excel.CurrentWorkbook(){[Name="GetFolder"]}[Content]{0}[Column1],
Source = Folder.Files(FilePath),
And well it kind of works.... When I set it up it works perfectly. But when performing a test run I noticed it wasn't working at all.
As mentioned, I use GetFolder as my named range. When the content of GetFolder changes value (a new folder path) , Power Query don't register it....not even if I update all. The DataSource don't update to the new value at all...weirdest part is, if I open advanced editor and just briefly change GetFolder to Getfolder2 in FilePath = Excel.CurrentWorkbook(){[Name="[B]GetFolder[/B]"]}[Content]{0}[Column1] I, of course get an error at first, but THEN when I the change it back to GetFolder, the new value is now registered. What, Why Pfft!? Why can't it just do that initiarially...it's the same line! I really don't understand. It's like the Query can't update it's data source value automatic. It can "read" GetFolder just fine or else I would get an error, so why the h... don't it update automatically It kind of ruins the whole purpose of doing this if it doesn't help the user. It's really not a bonus if I have to explain to users, that they just have do open this and this and enter advance editor and just change the Name="GetFolder" briefly and then back. It's REALLY annoying!!!! Can anybody pleeeeease explain this for me?