Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

How to identify specific rows to keep or remove in a group using formula

Althelp
6 - Meteoroid

I have data consisting of multiple groups shown below. Within each group, I need to identify specific records to keep, and specific ones to remove. I have manually done this in the column Keep or Remove but I want to recreate the last column using a formula.

 

I want to start from the latest date in each group (last row with date in ascending order) and Keep all the rows (starting from the last row in group and moving up) that sum up to the value in column A from bottom up until the entire value of column A is used up. All other remaining rows would be marked as Remove.

 

What I'm looking for is something where it checks the value of column B (in the last row with the latest date) against the value in column A in the same row. If the value of B is less than or equal to value of column A , mark row as Keep if not mark as Remove. Now we move up one row with the next latest date, if value of column B plus the sum of all the previous Keep column B's is less than or equal to the value in column A, mark as Keep, if not mark as Remove. Moving on to the next row up, if the value in column B plus the sum of all the previous Keep column B's is less than or equal to the value in column A, mark as Keep, if not mark as Remove. 

 

Essentially what I am looking for is a formula for the last column that can do what I am describing above for the below data set.

 

See below for an example table:

GroupABDateKeep or Remove?
1325/2/2022Remove
1325/2/2022Remove
1325/4/2022Remove
1325/4/2022Remove
1315/4/2022Keep
1325/11/2022Remove
1325/17/2022Remove
1326/1/2022Remove
1326/7/2022Remove
1326/13/2022Remove
1326/20/2022Remove
1326/24/2022Keep
2415/17/2022Remove
2416/1/2022Keep
2416/7/2022Keep
2446/13/2022Remove
2416/20/2022Keep
2416/24/2022Keep
3216/1/2022Keep
3216/7/2022Keep
3246/13/2022Remove

 

10 REPLIES 10
grazitti_sapna
17 - Castor

Hi @Althelp, give this a try.

grazitti_sapna_0-1657087287690.png

 

I hope this helps!

Thanks!

Sapna Gupta
Labels
Top Solution Authors