Forum Discussion
Power Query - Dynamically referring to correct file name in one drive
Hi,
Can I have your help on dynamically referring to correct file name in one drive?
Situation
In one drive, there are multiple file created, such as the file name ending with "2025 - 06" and "2025 - 07" and "2025 - 08" and etc.
And I have a financial schedule, like "2025 - 07" file will not be final until Aug 13, therefore, I initiated a schedule table depending on the current date, like today is Aug 9, we use "2025 - 06". Then starting on Aug 13, we can use "2025 - 07" file.
In Power query, I have connected to schedule table and initiate a new query to look for version based on the current date. Today is Aug 9, so we use version 06. Finally, turn 06 as text "Today Version" in the new query.
Question
In the query which I connected to file, the source step has the following path
"\\mob\2025 - 06.xlsx"
I would like to dynamically change the file path by replacing 06 with "Today Version", and I have tried this
"\\mob\2025 - " & Today Version & ".xlsx"
But it was not working. I have this error message
Expression.SyntaxError: Token',' expected.
Can you please help me to see if I missed anything there? Thanks,
Please ignore my inquiry. I figured it out now.
4 Replies
- annatanHelper II
Please ignore my inquiry. I figured it out now.
- MasonMASuper User
Hello annatan
If in your situation I would create a Parameter (FileVersion) in Power Query and use it in the source.
For Parameter, set its default value from your schedule table and reference this parameter in the file path as in below M.
let Source = Excel.Workbook(File.Contents("\\mob\2025 - " & FileVersion & ".xlsx"), null, true), ... in SourceIf you would like to try this, please also make sure "Today Version" is a single text value and verify the path syntax.
Hope it helps:)