Alteryx Designer Discussions

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

Need Help For Nested IF

5 - Atom

Hi Alteryx Community.

I am new user for Alteryx Designer.

I am trying to implement below logic in my Workflow.


IF [Concate]="110111" THEN ([RowCount]<=6 && [RowCount]>=10) ELSEIF [Concate]="110010" THEN ([RowCount]<=6 && [RowCount]>=13) elseif [Concate]="101111" THEN ([RowCount]<=3 && [RowCount]>=7) elseif [Concate]="001111" THEN [RowCount]>=7 elseif [Concate]="000111" then [RowCount]>=10 else [RowCount]<=18 endif


Here goal is to filter out number of rows based on Concate column values.

in first scenario if concate is "110111" I want Rowcount 1 through 6 and Rowcount 10 through 18.

Similarly for rest of scenarios.


Any help will be Appreciated.

14 - Magnetar
14 - Magnetar

Not quite sure I understand without seeing some sample data and knowing exactly what you mean by "I want row count...", but I interpreted it as "Okay, I have records in a data file, and a field called Concat.  For each record in the file, if Concat is some value, and the row number for the record is within some range, then keep the record, otherwise, discard the record.


If that's the case, then you might want to add a record ID to your file (Record ID tool), and then use a formula tool to create a field called "KeepRecord", and maybe a formula for that KeepRecord field of the following (I use Boolean IF/THEN statements, so forgive me for not having the ELSE's in there):


IIF([Concat]=="11011" && [RecordID]<=6 && [RecordID]>=10,1,
IIF([Concat]=="11011" && [RecordID]<=10 && [RecordID]>=13,1,


and so on.


And then put a Filter Tool next, and set the filter to KeepRecord==1.

5 - Atom

Thanks Mrbarone.

Rowcount is field generated with GenerateRow functions.

For each units I am adding 18 rows. Now based on Concatenate field values like 110011 or 110001 etc. I am selecting number of records . When I used If condition as I have given in my question it is not working on && condition.

It is same case in IIF with Boolean expression suggested by you.

At the End my final data Rows will be equal to or less than 18 based on Concate Field values.

Hope It helps understand requirement.



7 - Meteor

I recreated your problem and I think the solution is using the filter tool and paste your logic statement in the custom filter section. 

Here is the correct logic:


IF [Concate]="110111" THEN ([RowCount]<=6 or [RowCount]>=10) ELSEIF [Concate]="110010" THEN ([RowCount]<=6 or [RowCount]>=13) elseif [Concate]="101111" THEN ([RowCount]<=3 or [RowCount]>=7) elseif [Concate]="001111" THEN [RowCount]>=7 elseif [Concate]="000111" then [RowCount]>=10 else [RowCount]<=18 endif


When you used && that didn't work because for example you can't have one record be both under 6 and over 10 at the same time... I think the correct way is to use "or"


Hope that helps!

5 - Atom

Thanks very much SeanNelson2002.


It works Perfectly.


Thanks for Help.