Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Sort by two dimensions

Hello, I have a script with clients and dates and I would like to get a table sort by clients and dates. Then use the above function  to calculate a delay between each customer's date. Is this possible? Thank you for your help


Data :

load* Inline

[Customer, date, order, amount

4189,17/03/2015,45988038,73

6745,22/10/2017,46351840,66

5607,12/08/2016,46237091,83

1000000963,02/06/2016,32897484,105

1000000369,22/12/2017,46296443,97

6745,05/03/2017,32503124,116

1000000963,02/06/2016,32897484,105

400483848,23/05/2017,46102582,33

1000000369,03/07/2017,32602883,99

1000000369,08/05/2016,32721423,102

1000000593,18/05/2017,32342821,26

1000000369,06/07/2015,32909680,149

5607,13/08/2017,46238408,61

4189,22/10/2017,46351840,66

1000000593,19/05/2017,32342821,26

1000000963,02/06/2016,32897484,105

4189,22/10/2017,46351840,66

1000001048,25/08/2017,32694333,160

];

13 Replies
sumanta12
Creator II
Creator II

Hi Saoud,

Sorry....

Not understood your requirement. Can you please explain again.

sumanta12
Creator II
Creator II

Hi,

Please try this:

Data :

load * Inline [

Customer,date,order,amount

4189,17/03/2015,45988038,73

6745,22/10/2017,46351840,66

5607,12/08/2016,46237091,83

1000000963,02/06/2016,32897484,105

1000000369,22/12/2017,46296443,97

6745,05/03/2017,32503124,116

1000000963,02/06/2016,32897484,105

400483848,23/05/2017,46102582,33

1000000369,03/07/2017,32602883,99

1000000369,08/05/2016,32721423,102

1000000593,18/05/2017,32342821,26

1000000369,06/07/2015,32909680,149

5607,13/08/2017,46238408,61

4189,22/10/2017,46351840,66

1000000593,19/05/2017,32342821,26

1000000963,02/06/2016,32897484,105

4189,22/10/2017,46351840,66

1000001048,25/08/2017,32694333,160

];

DATA1:

LOAD

*,

FABS(date-PREVIOUS(date)) AS INTERVAL

RESIDENT Data ORDER BY Customer,date;

DROP TABLE Data;

Anonymous
Not applicable
Author

thanks a lot

Anonymous
Not applicable
Author

not exactly because the delay between two different customers must be zero

I have  a good answer by antoniotiman

If(Customer=Peek(Customer),Interval(date-Peek(date),'DD'),0) as Diff



thanks for your help