VeraData Batch Macro Use Case
In this post, we’d like to share a real life example of how VeraData utilized a Batch Macro. This specific task was provided to a client that required additional data processing.
Client request: Single out a random number of names from each state in the database.
We didn’t receive any additional criteria to base our selection on, so we’ll need to take a pre-determined quantity for each state from our processed file.
Resolving idea: Create an excel file (it can be in any format that you prefer). We’ll pull all states and proper quantities for each, to create a batch macro; this will process the data automatically.
Advantages of this approach: the main goal is to reduce our time-spent (time needed for implementing this task manually was like 2 hours as opposed to just minutes) and create the template for similar tasks in the future.
Implementation Part 1. Building the macro.
-Before you begin working on the implementation, think about the goal, scheme, and structure of the workflow.
-You’ll need to separate all necessary tools for the main workflow, which will also contain input and output tools.
-The next step is to build the macro workflow.
-Insert the macro input and macro output tools and begin building the mechanism of data processing that relates to your goal.
In the first workflow we locate input/output tools and as I mentioned before, will consist of macros and a few summarize tools to compare the results for implementation.
The macro's workflow contains required actions for state selection and quantity processing.
On the two slides below, you can see examples of each workflow:
![Post 7 1.jpg Post 7 1.jpg](https://community.alteryx.com/t5/image/serverpage/image-id/5456i94D8ACC81DC6ABBB/image-size/original?v=v2&px=-1)
![Post 7 2.jpg Post 7 2.jpg](https://community.alteryx.com/t5/image/serverpage/image-id/5457i1276CBBFC40FE934/image-size/original?v=v2&px=-1)
A few key points that you should keep in mind at this step:
1- Make sure that you understand 100% of the goal.
2- Choose the most effective option for resolution.
3- Start from the usual workflow - insert all of the necessary tools and think about what your macros will do.
4- Create the macro workflow and begin inserting the elements.
Resolution: Choose the state.
To choose the state, we used the Filter tool, Control Parameter tool, and Action tool. In the Filter tool we selected the “State” field from the Database. Then, we created the cyclical process, which takes the current field from the Database and replaces the selected state from the Example file (Action tool). The Control Parameter tool connects your macros to the main workflow, which we’ll describe in more detail a little bit later.
Now, the only thing you’ll need to do is set the configuration in the Action and Filter tool. In the Filter tool, simply choose any state that you prefer. In the Action tool click “Replace a specific string” and type in the string beneath name of the state that you’ve selected.
The slide illustrated below describes what the configuration should look like:
![Post 7 3.jpg Post 7 3.jpg](https://community.alteryx.com/t5/image/serverpage/image-id/5458iC214FDF235B4557E/image-size/original?v=v2&px=-1)
After that, utilize the Control Parameter tool, Action tool and Sample tool. We need to take the necessary quantity, so we’ll use the Sample tool for this.
Configuration of this tool is described in the next slide:
![Post 7 4.jpg Post 7 4.jpg](https://community.alteryx.com/t5/image/serverpage/image-id/5459iD314F4F6CA4F0EAC/image-size/original?v=v2&px=-1)
And the configuration for the Action tool:
![Post 7 5.jpg Post 7 5.jpg](https://community.alteryx.com/t5/image/serverpage/image-id/5460i6552AF2501783C79/image-size/original?v=v2&px=-1)
In addition, the screenshots below visualize the examples of configurations for the Control Parameter tools:
![Post 7 6.jpg Post 7 6.jpg](https://community.alteryx.com/t5/image/serverpage/image-id/5461iC7471F0A01713CEF/image-size/original?v=v2&px=-1)
![Post 7 7.jpg Post 7 7.jpg](https://community.alteryx.com/t5/image/serverpage/image-id/5462i975B1600FD7C7620/image-size/original?v=v2&px=-1)
Everything described above is just the first phase of implementation. In the next post, we’ll share the steps to connect the macros to the main workflow and of course provide a few useful tips for using macros.
Please share any thoughts you might have so far!…...