Alteryx Designer Desktop Discussions

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

Deleting Rows

Carolyne
8 - Asteroid

How would can I get this code to work right: In the first line, the end date is greater than the second start date I'd like to delete the 2nd, 3rd, 4th line and leave the 5th line since the start date in the 5th line is greater than the end date in the first line. Thank you.

 

Customer IDStart DateEnd _DateInvoice ID
12/28/20193/6/2019125
13/1/20193/3/2019489
13/2/20193/3/2019123
13/4/20193/5/2019456
15/5/20196/1/2019236

 

End result

 

Customer IDStart_DateEnd_DateInvoice ID
12/28/20193/6/2019125
15/5/20196/1/2019236
2 REPLIES 2
CharlieS
17 - Castor
17 - Castor

Hi @Carolyne 

 

The "deleting rows" here will be achieved by filtering our data to only the rows we want to keep. Defining the rows we want to keep can be achieved with a few Multi Row Formula tools.

 

- In Alteryx, the DateTIme functions only work with fields formatting in the ISO 8601 date format (YYYY-MM-DD). I start this process by using a Multi Field Formula tool to convert the two string fields with date information into this format and change the field type. I also added a Sort here to make sure the start date values were sequential.

- Now that we have the date fields, we can begin applying some sequential logic. I start by establishing a [LocalMax] value of End Dates. This is the sequence of the greatest End Date value.

- With the running [LocalMax], I can use another Multi Row Formula tool to determine if the start date for each record is greater than the previous [LocalMax] value, so we know that we want to keep that record.

- Finally a Filter will return on the field we want to keep and a Select tool will remove the additional fields I created.

- As a final note, I also added a "GroupBy" on the [Customer] field so this sequential analysis will be evaluate each Customer separately. 

 

Check out the attached workflow and let me know if you have any questions. 

 

20200403-Delete Rows.PNG

Carolyne
8 - Asteroid

Thank you so much.

Labels