Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
tomovangel
Partner - Specialist
Partner - Specialist

Previous type for each product, grouped by each customer

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 :

ClientIDTypePreviousType
Josh1Custom-
Josh2DealerCustom
Josh3RegularDealer
Alisa4Custom-
Alisa5RegularCustom
Alisa6DealerRegular
Alisa7RegularDealer
Alisa8RegularRegular
Alisa9DealerRegular




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, 

1 Reply
dplr-rn
Partner - Master III
Partner - Master III

almost there change your join statement to below
if(previous(Client)=Client, previous(Type)) as PreviousType