Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, Guys
I have been Struggling to get the previous type for each product, per each customer only.
So basically at the end of the script, i need to have a field, which shows me the previous product's type per each product for each customer.
I have attached an application. The desired result is :
Client | ID | Type | PreviousType |
Josh | 1 | Custom | - |
Josh | 2 | Dealer | Custom |
Josh | 3 | Regular | Dealer |
Alisa | 4 | Custom | - |
Alisa | 5 | Regular | Custom |
Alisa | 6 | Dealer | Regular |
Alisa | 7 | Regular | Dealer |
Alisa | 8 | Regular | Regular |
Alisa | 9 | Dealer | Regular |
this is my script
test:
LOAD * INLINE [
ID, Type,Client
1, Custom, Josh
2, Dealer,Josh
3, Regular,Josh
4,Custom,Alisa
5,Regular,Alisa
6,Dealer,Alisa
7,Regular,Alisa
8,Regular,Alisa
9,Dealer,Alisa
];
left join
LOAD ID,
previous(Type) as PreviousType
RESIDENT test
Order by ID asc;
Best Regards,
almost there change your join statement to below
if(previous(Client)=Client, previous(Type)) as PreviousType