Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Inputting Data with the 'Input Data' Tool

Daniel_Ajao
6 - Meteoroid

Is there any way to configure the 'data input' tool so that it brings in the most recent file from a folder

Say for example in Folder A we have file20170919.xls for Tuesday and file20170920.xls for Wednesday ... I'd like to be able to configure tool to input the file20170919.xls on Tuesday and then on Wednesday, the file20170920.xls and so on for the other days except weekends ... Is this possible? Thanks!

9 REPLIES 9
Claje
14 - Magnetar

Hi,

I don't think that the regular Data Input tool will allow you to do this exactly.


However, a combination of the Directory tool and the Dynamic Input tool should let you do this.

Basically you can set up your directory tool to point to your folder location and search for file*.xls inside folder A. 

This will include some information like the last time the file was saved, or the filename, and you can use a filter to identify which file should be loaded on a given day.

After that, you can use dynamic input and update the file path completely, to read in the newest file.

NicoleJohnson
ACE Emeritus
ACE Emeritus

If the file name will always be the same base name + today's date in format yyyymmdd, you can also use a formula like this to create the filename that then feeds into the dynamic input tool: ="file"+DateTimeFormat(DateTimeToday(),"%Y%m%d")+".xls"

 

NJ

Daniel_Ajao
6 - Meteoroid

Thanks Nicole ... the concatenated string that you provided goes into the Directory tool right?

NicoleJohnson
ACE Emeritus
ACE Emeritus

No, in this case you won't need the directory tool. The concatenated string will specify the filename (assuming they are always consistently named as such) and then you can feed that directly into the Dynamic Input tool. You'll set up your initial connection to a file in the Dynamic Input tool and then choose the option to replace the filename with the concatenated filename (containing the updated date as part of the file name) to replace the filename initially used in the Dynamic Input tool. Does that help?

 

DynamicInput.JPG

Daniel_Ajao
6 - Meteoroid

Thanks Clajet ... would you be able to provide more specifics as to how use dynamic input and update the file path, 

I used the concatenated expression provided by Nicole in the 'File Specification' field of the Directory tool but I am getting zero output ... Thanks!

Claje
14 - Magnetar

Hi,

If you're looking to use the Formula approach recommended by Nicole, you'd probably want to use a Text Input to start your workflow off instead.  I would actually recommend a slight tweak to use the text input tool to read in the first part of the file name.

 

I called it fileprefix for my example below:

[fileprefix]+DateTimeFormat(DateTimeToday(),"%Y%m%d")+".xls"

Here's a quick screenshot:

 

DynamicInputCommunityExample.png

Daniel_Ajao
6 - Meteoroid

Thanks Claje/Nicole apologies still pretty new to Alteryx here ... I followed yours and Nicoles steps and would you know why I am now getting a 'missing incoming connection' error on the formula tool

 

images in the docx file.

Claje
14 - Magnetar

Hi,

I think if you just put a Text input tool with at least 1 line of data in before the formula, this error will go away.

Daniel_Ajao
6 - Meteoroid

Thanks Claje/Nicole for your support, was finally able to come up with a solution based on both your ideas, I ended up using both a directory and a formula tool ... what I wanted to mention for benefit of others is that you might want to use the 'Modify SQL Query' Option of the Dynamic input tool to replace the filename of your template.

So say your input data source template is c:\022018.xlsx , use the "Replace A Specific String"  under the "modify sql  Query Option" to take off the 022018.xlsx to then be replaced with whatever filename you have passed into the Dynamic input. Screenshot of my workflow and another useful Alteryx link   in the doc attached.

Labels