Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Dynamic file name and dynamic file path

ashamluo
7 - Meteor

Hello,

 

I am trying to get a report from a dynamic path, but the report also have a dynamic name. 

I tried pulling the path from directory tool, but there are too many folders, subforders and files which takes a long time for directory tool to run.

I thought in using dynamic input to change entire file path, but I cannot think of a way to recognize the latest dropped file on certain day.  

 

This is an example of what I am trying to do:

Under document folder there are many subfolders with lots of subfolders, but I am only interested in 'MathReport' folder, then today's date is 2023-03-08 I am interested in today's folder, in this case is '20230308' folder (Pic#1).

From many subfolders I only want to know about the files in the 'Summary' folder (Pic#2).

And I would like to select the oldest report for previous day, report name would be dynamic since it has time stamp. In this case, previous day file with the last dropped timestamp would be 'summary_report_20230307_200535' (Pic#3)

 

Pic #1

ashamluo_0-1678376872278.png

 

Pic #2

ashamluo_1-1678376913899.png

 

Pic#3

ashamluo_2-1678376938144.png

 

 

Thnak you in advance

 

 

 

1 REPLY 1
mceleavey
17 - Castor
17 - Castor

Hi @ashamluo ,

 

You need to determine the latest file, correct?

 

Use the Directory tool to look into the "MathReport" folder. Ensure you have the "Include Subdirectories" box checked and you have narrowed down the name of the reports you want as much as you can (only the generic parts):

 

mceleavey_0-1678381368350.png

 

This will load in the metadata from these reports, including the date and time the file was created:

 

mceleavey_1-1678381460567.png

 

Sort by this field descending, then use a sample tool to select the first 1 record. This will be the latest file. You can repeat this process by using things such as datetimediff functions between this creation time and the current datetimenow() function. This will allow you to select the files you need. You then simply need a dynamic input tool to load these files in.

NOTE: If you don't want to use the created time field, you can simply parse the date from the filename.

 

I hope this helps,

 

M.



Bulien

Labels