We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Filter every other row (Odd/Even Rows)

gaoa
11 - Bolide

Does anyone know how to filter every other row in a large dataset with 300k+ rows? Assuming we need both odd and even rows in the output, and there is no other condition to filter. I thought of using the Sample tool but that only returns half the answer. And due to the large number of rows, it would be unrealistic to use the Select Records tool either...

 

gaoa_0-1677310496938.png

 

3 REPLIES 3
binuacs
21 - Polaris

@gaoa something like this

binuacs_0-1677316050204.png

binuacs_1-1677316066391.png

 

 

RobertOdera
13 - Pulsar

Sure thing, @gaoa 

 

Consider the below:

1. add a sort tool for your primary field to make sure you have the order that you need

2. add a record ID tool with field recID and field type Integer 64

3. add a formula tool where column Is_Even is given by: IF Mod([recID]), 2) =0 THEN 1 ELSE 0 ENDIF. However, if your record ID was a text, then use IF Mod(ToNumber([recID]), 2) =0 THEN 1 ELSE 0 ENDIF

4. add a filter tool where Is_Even = 1, and this will split your flow into Even recID out of the true node and Odd recID out of the false node

5. add a union tool at the end of your process if needed to stack the data back into a single table

 

-Also consider using the Auto Field tool in your flow if you want to make your set as "light" in term of of field size --> processing time --> memory

 

Please mark it as an acceptable solution if this works for you - Cheers!

RobertOdera
13 - Pulsar

You're very welcome @gaoa 

Labels
Top Solution Authors