Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Restrict the row generated by Directory

ankurrjit
8 - Asteroid

Hello All,

 

Is there a way to restrict the rows generated by a DIRECTORY tool. I have a path that holds folder from 2018 for every single day like 20180101, 20180102....20200604.

 

whenever I run the workflow, it takes 24 minutes to read all these files and produce rows info. How can I restrict the no of rows read by the directory to read-only folders from 20200101 onwards and ignore other folders.

 

ankurrjit_0-1591281833329.png

Best Regards

Ankur Tyagi

13 REPLIES 13
ankurrjit
8 - Asteroid

Thanks, @DavidP  I really appreciate your help, I am sorry to be a pain but where do you have to define to replace the file with today's date? I can see you are manually selecting "replace a specific string" with "DAILY_01282020". I am trying to understand in the batch macro where should we define to get today's date?

DavidP
17 - Castor
17 - Castor

Here's an example where the folder path ends in a date folder with format yyyymmdd

 

The workflow replaces that date with today's date that then dynamically changes the folder path in the macro.

 

DavidP_0-1591337913667.png

 

DavidP
17 - Castor
17 - Castor

So from the pic below, you can see that in the macro, I set the Directory tool up with some placeholder information:

 

1. Folder path is C:\Users\david\Documents\Alteryx\Diectory tool test folder

2. File Specification is RTL_SAP_SD1_INVENTORY_BALANCES_DAILY_01282020_*

 

With the 2 control parameters and action tools, I then tell the macro to update these values at runtime as follows:

 

1. Replace the entire folder path with the value of the field that is picked for the Folder Path question

2. Replace DAILY_01282020 with the value of the field that is picked for the File Specification question

 

Then in the workflow, I specified the folder path in the Text Input tool and used the DatetimeNow tool to retrieve today's date and then convert it to the format DAILY_mmddyyyy

 

You'll see in my last post that I modified the workflow so that the Folder Path ends in a date folder of the format \yyyymmdd and then use a formula to replace that date with today's date in the same format. Now when the workflow is run, it will only search in the path with today's date folder.

 

Now that you're only looking at the files in today's folder, you can probably change the File Specification in the Directory tool inside the macro to *.* and remove the control parameter and action tool on the right that updates the File Specification. 

 

Remember to save the changes in the macro if you do this. You can then simplify the workflow and remove the DatetimeNow, Select, Formula and Append fields tools and simply keep the Text Input and Formula tools to feed the Macro.

 

 

DavidP_0-1591338443743.png

 

 

 

ankurrjit
8 - Asteroid

Thanks a ton @DavidP .

 

Sorry for the delay in response. This was a whole new concept for me and took a bit of time to understand but in the end it worked perfectly I wanted it and the way you explained in your post. Thanks for taking the take and providing a detailed solution.

 

Best Regards

Ankur Tyagi

Labels