Parameter to pass folder (static) and file name (dynamic) to a query as a source file

rgs694

New Member
Joined
Sep 18, 2013
Messages
30
Been searching all over for this one. I've found help with how to set up an Excel table to feed a dynamic file name into PQ as a source, but I want to set up a parameter as a query that references the same folder all the time with the file name changing upon download. Thought I had set this up correctly but the source is not refreshing with each latest version of this download.

My PQ process is set up as follows:

1. My firm's report data automatically downloads to my computer's Download folder as an Excel CSV file. The latest version of this file is what I'll use to refresh my existing workbook (WB) query (3-12 times a day). Sample file path and name: C:\Users\me_myFirm\Downloads\TradeDetails10_27_2023 4_23_43 PM.csv

2. A pre-existing connection-only query references my Download folder > filters the folder's Date Modified column for "is latest" > adds a column to concatenate [Folder Path]&[File Name]&[Extension] > remove other columns > converts this path to List. Identical text as the file above.

3. A pre-existing parameter is set up as query, using the connection-only query above. The parameter is called SourceParam.

4. I replaced the static file source location of my main WB query with the parameter above: = Csv.Document(File.Contents(SourceParam))

I don't get any errors after adding this parameter to the source step, and all the subsequent 20 steps work, but the 'latest' source file isn't being referenced. It's still referencing the older file from my original parameter set-up.

Is it something in the types: lists vs queries vs tables? Or maybe a privacy/security issue using the computer's Download folder? I'm OK with basic PQ set up and loading into Excel, but probably over my skis here. Any insight would be greatly appreciated.

Thank you!

-Rich
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
What does the first line of your query look like. Show us the Mcode that indicates the source for the query.
 
Upvote 0
What does the first line of your query look like. Show us the Mcode that indicates the source for the query.
= Csv.Document(File.Contents(SourceParam))

I may have had other delimiter syntax in there previously but was still getting errors. Thank you!
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,121
Members
453,021
Latest member
Justyna P

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