duranimal86
New Member
- Joined
- Jul 24, 2019
- Messages
- 18
- Office Version
- 365
- Platform
- Windows
I have a Power Query setup to pull the data from a file saved on SharePoint, but each month the month # in the filename changes. How can i setup the query so that it always pulls from the file based on the rest of the filename that doesn't change. For example, last month it was "P07 Account List.xlsx" then still be able to refresh and automatically pull from "P08 Account List.xlsx" this month (i was unable to update my current query). So I just want to pull the PXX Account List.xlsx, no matter what month number is in the file name (there should only ever be one, but i could put in a sort on date created to get the most recent just in case), and then pull everything from the first sheet into a table in my excel file. I am able to navigate to the SharePoint folder and use the filters to get the list down to the "PXX Account List" file that i want, but then i can't figure out the next step of picking the sheet and pulling that into a table in my excel workbook without those steps using the current filename that won't be able to refresh when the name changes.
I have seen plenty of examples of having named cells in the file and getting the filepath and then entering the changing numbers to manually create the dynamic filename and pointing the source to that named cell, but there are a couple reasons that won't work for me. Because of a couple ways the query will be used, i need the dynamic selection to all be built into the query code and not require any manual input other than refreshing the query.
I have seen plenty of examples of having named cells in the file and getting the filepath and then entering the changing numbers to manually create the dynamic filename and pointing the source to that named cell, but there are a couple reasons that won't work for me. Because of a couple ways the query will be used, i need the dynamic selection to all be built into the query code and not require any manual input other than refreshing the query.
Last edited: