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.

Input File - Conditional Workflow run

skotian1289
8 - Asteroid

Hello All,

 

I have created a workflow where multiple formulas and conditions are applied to a input file. However my input files will differ and I do not want all the conditions/formula to apply . Let me try and give a simple example which might help understand better.

 

1.) suppose My workflow has 3 conditions to be applied to any input file: Condition 1 (Fomula to add the values of column AA and AB)

                                                                                                                    Condition 2 (Add 3 additional rows on top of input file)

                                                                                                                    Condition 3 (Multiple 5 to values of column C )

 

2.) Currently these 3 conditions will apply to all input files when we run the workflow, however I do not want that.

 

3.) If lets say Input file name includes "FRANCE" the condition 2 of the workflow should be deactivated and only Condition 1 and 3 should be applied to the input file, similarly if file name includes "SPAIN" only condition 3 should be applied rest condition 1 and 2 should be deactivated.

 

Is it possible to do a conditional workflow running in Alteryx?

 

Thanks and any help is appreciated.

 

                                                                                                            

5 REPLIES 5
Qiu
20 - Arcturus
20 - Arcturus

@skotian1289 
For a start, we can check the hint from solution of this post.

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Conditional-Workflows/td-p/7097

Sorry , let me think something else

AngelosPachis
16 - Nebula

Hi @skotian1289 ,

 

I think you can make this work following a batch macro approach. Assuming your input looks something similar to this,

 

AngelosPachis_0-1609748632388.png

 

You can create a conditions input which will be fed in your control parameter and will contain which conditions should be applied to each country. So conditions 1 and 3 are those you have provided and condition 2 is to generate 3 rows.

 

AngelosPachis_0-1609749903633.png

 

 

Then, inside your batch macro you can think of it as a workflow that will run for each record you feed in the control parameter. So for the first run, Country will be France and the condition will be [AA]+[AB].

 

AngelosPachis_2-1609748845866.png

 

Country will replace the value in the filter, so in that run Spain will be replaced with France and you will only keep records related to France from your input.

 

Then in the formula tool, you will feed in the expression that you want to apply, so for France-Condition1 then the expression will be [AA]+[BB] else for France-Condition3 that expression would be 5*[C].

 

Then I've used a filter tool to split the records in case the condition is number 2, where you have to generate 3 rows and stack them at the top of the old datastream.

 

Let me know what you think of it, of course there is further room to refine this more but this logic meets the requirements I reckon. The output looks something like this

 

Screenshot 2021-01-04 083109.jpg

Hope that helps.

 

Regards

 

Angelos

 

 

 

skotian1289
8 - Asteroid

@AngelosPachis - Thank you for your response however the name word "FRANCE" "SPAIN" and so on will be part of input file name and not the data, sorry I was not very clear in my earlier message, I am attaching few sample input file for you this time.

 

I have created a workflow which I want to use for multiple input files, however there is a possibility that few input files might not have specific columns so for those input file I want the formulas/conditions to be freezed and workflow to go ahead with the rest of formulas/conditions.

 

1.) So Lets Say if we use "GERMANY Daily File" the workflow should run all 3 conditions.

 

2.) If we use "FRANCE Daily File" condition 1 and 3 should run however condition 2 should get frozen.

 

3.) If we use "SPAIN Daily File" only condition 3 should run and rest should get frozen.

 

Is there a way we can achieve this within single workflow or I will have to create a separate workflow for all other input files ?

 

 

Thanks and hope the sample input files and screen shots help you. Sorry once again.

 

 

 

 

AngelosPachis
16 - Nebula

Hi @skotian1289,

 

The workflow provided earlier would work even if the countries are in the Filename, but we have to make a couple of small changes.

 

First of all, you are going to need a way to read all of your files simultaneously. Because the files have different schema (Spain contains field BB which is not contained in the other Files) you will need a batch macro to do this.

 

There is quite a lot of a material on the community on how to create a batch macro to read in files of different schema, but please don't hesitate to ask any questions if something is unclear in the following explanation.

 

Step 1

 

Place all your inputs in a single folder and then use a directory tool to read the different file names and characteristic of each file. You should get 19 fields coming out of the directory tool, from which you are going to need a field called "FileName", which will have the following format 

 

COUNTRY Daily File.xlsx

 

Step 2

 

Configure the Batch Macro to Select the Filename. The filename column has 3 values for me based on the files you have provided, but you may have more.

 

AngelosPachis_1-1609791157721.png

 

Those three different FileNames are fed into the control parameter of the batch macro, which means that the workflow contained inside the macro will run once for each one of the control parameter records ( a total of 3 times for my case, once for France then Germany and finally Spain).

 

Inside your batch macro, what's going on is that the Input Data tool reads one file from the designated directory each time it runs; the first time, the filename would end in "FRANCE Daily File.xlsx" and the table from France file will be inputted. Then, the control parameter will update the Filename string to end in "GERMANY Daily File.xlsx" instead, so the table from Germany will be inputted,

 

The batch macro is configured to output the results based on the field names (similar to a union tool), so field that are common will be stacked on top of each other and fields that are not common will be outputted but missing values will be Nulled.

AngelosPachis_3-1609791818175.png

 

The batch macro output will look something similar to this, so now you have read all tables from the different files, and you have the country column to differentiate among them:

AngelosPachis_4-1609791849946.png

 

Step 3

 

Then I've gone on and configure the Text Input tool to the Conditions that I want to apply in each file.

 

Screenshot 2021-01-04 202539.jpg

 

Step 4

 

So the second batch macro will now run and apply the conditions to each file. The output will look something likes this:

 

AngelosPachis_5-1609792013482.png

 

So for the first 5 records (Germany) condition 1 has been applied ([AA]+[AB]) so under column 1 you get the corresponding values; many nulls because [AB] is null, but then 105=98+7.

 

I know the output is somewhat messy, but if you provide a desired output format we can amend it as necessary.

 

Hope that helps, let me know if you have any questions on the above.

 

Regards,

 

Angelos

AngelosPachis
16 - Nebula

Hi @skotian1289 ,

 

Did you manage to get the answer right following the batch macro approach> Did it work for you at the end?

 

Thanks

 

Angelos

Labels