How to dynamically change folder path in Power Query each month?
Hi, I’ve been struggling with this for hours. Copilot and Gemini keep giving me code that doesn’t work.
I’m an accountant, and during month-end close I usually compile several reports and paste them into a folder. Then I run a simple Power Query that reads, transforms, and filters the data into a final table.
It works perfectly.
The issue is that every month I copy and paste the files into a new folder, and I have to manually edit the directory path in Power Query — for example:
C:\Users\wakiarg\THE COMPANY\THE SHAREPOINT - Documents\2026\2026-01\
Then I change it to 2026-02, 2026-03, and so on.
Is there a simple way to modify the M code so Power Query automatically detects the current month folder (e.g., -02, -03, etc.) instead of me having to manually update the path each time?
The IA gave me some ideas using =cell but it's giving me an URL instead of the local directory, and from there on its a mess.
Ideally, I’d like it to dynamically reference where the file is stored, as the folder is always there.
[link] [comments]
Want to read more?
Check out the full article on the original site