Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

if Statment with previous or any other suggestion

Hi guys

i have some sampledata but i cant get my If statment to work properly. It's a bit complicated but maybe somebody can help me out

This is the sample below

I want to know if a customer bought a Product in the 100 series and at the same date or six months before bought he/she bought a Product in the 200 series . Can I solve this with a IF statement and a PREVIOUS statement? or is there any other sulotion that's better to solve this problem?

thx Theo

   

CustomerIDStatusOrgnameDateProduct
482264512777DoneArpa2011-02-28103
482267968279DoneArpa2012-11-28101
4822611758575DoneArpa2014-11-17101
4822613524439DoneArpa2015-10-15111
3409714338835DoneBionic2016-03-08112
3409717512118DoneBionic2017-09-14112
539298509813DoneNatsa2013-03-14103
343019501047DoneGerud2013-09-26101
343019501048DoneGerud2013-09-26205
343019501050DoneGerud2013-09-26103
343016168311DoneBerud2012-01-03103
33929701178DoneBerud2009-02-04103
339291030821DoneBerud2009-04-16103
6000014697650DoneBluqa2016-05-11103
6000014750969DoneBluqa2016-05-19204
6000014795514DoneBluqa2016-05-26206
6000014918893DoneBluqa2016-06-17103
1 Solution

Accepted Solutions
marcus_sommer

I'm not sure if you could get it to work with previous/peek-functions within if-loops because you would need to define how many iterations are max. possible and to sort your table to all of your conditions. I would probably try to get this informations with join/keep-loadings like:

table1:

load Customer, Date from Source where Product = '1??';

     concatenate(table1)

load Customer, addmonths(Date, -6) as Date from Source where Product = '1??';

inner join(table1)

load Customer, Date from Source where Product = '2??';

   

- Marcus

View solution in original post

2 Replies
marcus_sommer

I'm not sure if you could get it to work with previous/peek-functions within if-loops because you would need to define how many iterations are max. possible and to sort your table to all of your conditions. I would probably try to get this informations with join/keep-loadings like:

table1:

load Customer, Date from Source where Product = '1??';

     concatenate(table1)

load Customer, addmonths(Date, -6) as Date from Source where Product = '1??';

inner join(table1)

load Customer, Date from Source where Product = '2??';

   

- Marcus

Not applicable
Author

worked like a charm thx