Alteryx Designer Desktop Discussions

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

Filtering Multiple Columns

bogdansheremeta
7 - Meteor

Below is my sample of data:

[Data]                              [Sacramento?]        Delinquent

Ha                                      No                            No

Da                                      No                           No

No                                      No                          No

Sacramento                       Yes                             No

Ha                                      No                           No

Delinquent                         No                           Yes

 

I need to proceed with my workflow only if there is a Yes on Sacramento and a Yes on Delinquent. So a Filter tool. However, I cant use IF AND as it will not work. Any suggestions on how to make this work? 

13 REPLIES 13
DataNath
17 - Castor

If you need to filter out anything that isn't a yes for both Sacramento and Delinquent then that's definitely the way to go. In your sample data none of the records satisfy that condition and so would all be filtered out/come out of the false (bottom anchor) of your Filter tool. I added an additional row that would hit this criteria and the Filter works as per your requirement, unless I'm missing something? Also, I notice you mention 'IF' in your original post. When writing expressions in the Filter tool, you don't write it as a full if statement, just the actual condition. The tool has True and False output anchors and so you just need to put in a boolean expression that will check whether or not something is True/False and output data will via the corresponding anchor, i.e. [Field 1] > [Field 2], or in your case, [Sacramento] = 'Yes' AND [Delinquent] = 'Yes'.

 

DataNath_1-1656546727817.png

 

DataNath_0-1656546709713.png

bogdansheremeta
7 - Meteor

How would you do it without an additional row? I have many other records of data afterwards and needs to be dynamic in checking these two columns

DataNath
17 - Castor

@bogdansheremeta the Filter tool will always just check those two columns as that's what is reference in the expression. I just added a new row to show you that it works, as none of the rows in your sample data would satisfy your criteria. If you place a filter into your own workflow with actual data and use the expression I did (below), does that give you what you expect?

 

 

[Sacramento] = 'Yes'
AND
[Delinquent] = 'Yes'

 

bogdansheremeta
7 - Meteor

No, because it looks for both of these conditions, "Yes" for Sacramento AND "Yes" for Delinquent. So for True there is nothing. Remove your "Do" row and you will see what I mean. 

DataNath
17 - Castor

In your original post you said 'I need to proceed with my workflow only if there is a Yes on Sacramento AND a Yes on Delinquent.'

 

So this would be the expression I posted above. If there are no true outputs and you're expecting there to be, are you sure you don't mean:

 

I need to proceed with my workflow only if there is a Yes on Sacramento OR a Yes on Delinquent.?

 

If so then you would use:

 

[Sacramento] = 'Yes'
OR
[Delinquent] = 'Yes'

 

If not then we'll obviously need to figure out the criteria you actually want to apply.

bogdansheremeta
7 - Meteor

That is correct. I "'need to proceed with my workflow only if there is a Yes on Sacramento AND a Yes on Delinquent." The problem is that it is Yes on row 4 for Sacramento  and Yes on row 6 for Delinquent. I guess a way I can solve this is if I add another row and make them both yes. How do I do that within Alteryx and not manually?

DataNath
17 - Castor

You could split the data into two streams and do the check separately, so you don't lose rows where the expression doesn't apply to both (i.e. all of them in your sample). However, I'm not sure how you plan/want to join them back together afterwards. In your example of rows 4 and 6 above, are they fine to be joined back together purely on position because they're both 'yes'? As there's obviously no other unique identifier to join them on, especially when you expand this to more rows in your full data set. Workbook attached:

 

DataNath_0-1656548083228.png

DataNath_1-1656548105002.png

 

flying008
14 - Magnetar

Hi, @bogdansheremeta 

 

Maybe this is your want result ? (In fact, you want get  [Sacramento] = 'Yes' and [Delinquent] = 'Yes' , I use [Sacramento] = 'Yes' or [Delinquent] = 'Yes' to explain the filter logic. Note that it is dynamically filtered when row value = field name.)

 

录制_2022_06_30_08_33_37_439.gif

 

Input   Output   
DataSacramentoDelinquent DataSacramentoDelinquentFilter
HaNoNo HaNoNo0
DaNoNo DaNoNo0
NoNoNo NoNoNo0
SacramentoYesNo SacramentoYesNo-1
HaNoNo HaNoNo0
DelinquentNoYes DelinquentNoYes-1
grazitti_sapna
17 - Castor

@bogdansheremeta, does this solves your purpose?

grazitti_sapna_2-1656568227667.png

 

 

Thanks!

Sapna Gupta
Labels