Alteryx Designer Desktop Discussions

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

Dynamic filtering the data on based on conditions.

Radhika
6 - Meteoroid

Hi All,

Can anyone help me with this scenario?

I have one input as a database, below is its format. I have some filter conditions to get data.

 

Each condition can vary on different columns of input with 'and' and 'or' conditions and in the output, I need 3 columns - Eid (from input ), Category, Code (created in the canvas based on conditions defined),

Required: I need to create an optimized alteryx solution (might be a batch macro) where I can have all the columns of the input and every time a new condition is given, I just need to add 'AND' and 'OR' conditions to those particular columns mentioned in the condition and generates a new output of 3 columns (Eid, Category, Code)  in the same canvas in which Category and code are generated during the flow as per the condition. Hardcode values will be given for Category and Code in every defined condition. 

 

Example : 

Input sample

EidProcess_dateDeptAssigned_teamLocationSal_currencyBase_locationUnitManager_NameDays
120-07-2022AAAZCADZZavhjAB1
221-07-2022BBBYINRYYyahjVBF2
322-07-2022BCCXJPYTTavhHG3
423-07-2022DDDWUSDWWkgsSJ4
5 24-07-2022EEEVCADVVnjhAJ5

 

Let's say I have condition 1 for 1st flow -

Dept =A and sal= CAD then category = 'def' and code ='11'

Output - Output should be

EidCategorycode
1def11

 

Condition 2 :

Dept=B and (assigned_team = bb or cc) and (unit = YY or TT) then category = 'GHI' and code ='22'

the output should be ;

EidCategorycode
2GHI22
3GHI22

 

The only constant column in every condition is 'Dept' then further with other columns.

Each record from input will validate each condition and give output for each condition. Each condition should produce its own output of 3 columns or  combined output will also work

Conditions may use any string functions on any column (for eg left(assigned_team,2)).

Here I have given two conditions only but there'll be around 100 so I need an optimised and automated data driven solution for this so that every time a new condition is added, I have to just add 'AND' and 'OR' conditions to the particular columns and gets output.

If anyone can help, Thanks in advance.

1 REPLY 1
mceleavey
17 - Castor
17 - Castor

Hi @Radhika ,

 

This is a simple combination of the Formula tool and the Filter tool:

 

mceleavey_0-1663175623662.png

The formula tool builds the logic to determine the Category and Code (I changed it as you appear to have made a mistake when you said Unit = YY or TT, but I think you meant Base_Location):

mceleavey_1-1663175701393.png

 

This populates the two columns, I then applied a filter to remove those records with blank Categories and Codes:

 

mceleavey_2-1663175745222.png

 

I think it would help if you learned more about the Formula tool and the Filter tool. You can find more information at the links below:

 

I hope this helped,

 

M.

 

https://help.alteryx.com/20221/designer/formula-tool

https://help.alteryx.com/20221/designer/filter-tool

 



Bulien

Labels