Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a list of many products joined with a date_1 column. I need to add a new field to get the previous date_1 value or the value of the date_1 if there is no previous:
Example:
table source:
Products | Date_1 |
1638 | 02/07/2018 |
1639 | 01/07/2018 |
1639 | 02/07/2018 |
What i want :
Products | Date_1 | Date_2 |
1638 | 02/07/2018 | 02/07/2018 |
1639 | 01/07/2018 | 01/07/2018 |
1639 | 02/07/2018 | 01/07/2018 |
I used this script :
load
Distinct
Product,
Date_1,
if(product = Previous(product),Previous(Date_1),Date_1) as Date_2
Resident Table_source
order by Product,Date_1 asc;
what i get with my script:
Products | Date_1 | Date_2 |
1638 | 02/07/2018 | - |
1639 | 01/07/2018 | - |
1639 | 02/07/2018 | 01/07/2018 |
Any ideas how i can handle that ?
Thanks in advance
Hi,
Maybe;
load
Distinct
product,
Date_1,
if(product = Previous(product),if(Previous(Date_1)=Null(),Date_1,Previous(Date_1)),Date_1) as Date_2
Resident Table_source
order by product,Date_1 asc;
Cheers,
Chris.
Hi,
Maybe;
load
Distinct
product,
Date_1,
if(product = Previous(product),if(Previous(Date_1)=Null(),Date_1,Previous(Date_1)),Date_1) as Date_2
Resident Table_source
order by product,Date_1 asc;
Cheers,
Chris.
It works !
thank you very much 😁