I currently have a schedule that drops a report with a date in the name.
The sample file name is transactions_20240311_0 and transactions_20240311_1
I need both files.
I know I can put a * on the input tool but then alteryx will be reading every single file in that folder when I only need the latest two files.
Any suggestions on how to get this to work?
Solved! Go to Solution.
Hi @Analyst323 you can see the other methods outlined in this article to search a directory to find the latest file. You may need to use a sample tool to limit the file to the two latest files.
Thank you! I ended up using the directory tool but that does seem like a good resource for other ways to bring in files.
Hey - so to clarify - a directory tool reads metadata about the files - the input data tool would read the file. You would use the directory tool to parse the filename (using something like datetimeparse(regex_replace([FullPath],"^.*transactions_(\d{8})_.*$","$1"),"%Y%m%d") to create a date field. you can then sort on that datefield - use the sample tool to extract the top two values - and then feed those into an input data tool in a batch macro.
Thanks for the suggestion! This is how I did it (without a batch macro):
You could actually just throw the whole thing in a filter rather than doing a formula and then a filter. Performance wise should basically be the exact same, just saves you a step.
Just configure your filter (Custom Filter option) to say: Left([CreationTime],10) = DateTimeToday()