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.

Add number of previous rows which are greater than current row date

jeffyfj
5 - Atom

Hi

 

I have a table which has a row per contract id. I have two datetime stamps - created and assigned. I need to group the data by created date, sort by created datetime column and calculate a new column "Arrival volume" which gives the sum of previous rows which are greater than current row assigned datetime.

Please suggest an efficient way to handle this query.

 

contract idcreatedassignedcreated dateArrival volume
812082114-09-2022 02:0314-09-2022 05:4414-09-20220
812086114-09-2022 02:3114-09-2022 10:4514-09-20220
812089114-09-2022 07:0314-09-2022 10:3014-09-20221
812094114-09-2022 08:3214-09-2022 11:1114-09-20220
812102114-09-2022 08:4014-09-2022 10:5714-09-20221
812103114-09-2022 08:5214-09-2022 09:3114-09-20220
808462115-09-2022 10:5415-09-2022 13:5015-09-20220
812327115-09-2022 10:5615-09-2022 11:3415-09-20221
811897115-09-2022 10:5815-09-2022 14:0415-09-20220
806035115-09-2022 11:0215-09-2022 13:2815-09-20222
812330115-09-2022 11:0615-09-2022 11:3115-09-20224
5 REPLIES 5
ShankerV
17 - Castor

Hi @jeffyfj 

 

Can you please highlight the logic why 2 and 4 are populated in Last 2 record.

 

 

ShankerV
17 - Castor

Hi @jeffyfj 

 

One way of doing this.

 

ShankerV_0-1684158162384.png

 

 

Many thanks

Shanker V

ShankerV
17 - Castor

Hi @jeffyfj 

 

Step 1: Input

 

ShankerV_0-1684158254182.png

 

 

Step 2:

ShankerV_1-1684158270504.png

ShankerV_2-1684158279379.png

 

 

Step 3:

ShankerV_3-1684158300170.png

IF datetimediff([Row-1:ISO date],[ISO date],"minutes")>0
THEN 1
ELSE 0
ENDIF

 

ShankerV_4-1684158308923.png

 

 

Many thanks

Shanker V

jeffyfj
5 - Atom

Hi Shanker

 

Thanks for the prompt reply. The logic for the last row is that it checks all the previous rows for created date of 15-09-2022. Accordingly, in rows 7-11, assigned datetime of rows 7,8,9 and 10 are greater than assigned datetime of last row. Hence arrival volume needs to be 4.

 

Thanks,

Jeffy

 

 

jeffyfj
5 - Atom

Hi Shanker

 

Thanks for the prompt reply. The logic for the last row is that it checks all the previous rows for created date of 15-09-2022. Accordingly, in rows 7-11, assigned datetime of rows 7,8,9 and 10 are greater than assigned datetime of last row. Hence arrival volume needs to be 4.

 

Thanks,

Jeffy

Labels
Top Solution Authors