Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
MK_QlikFan
Contributor
Contributor

To find customers who bought a product from a specific category on their first order

I have a dataset containing Order_id, Customer_id, Product_id, Product_name, First_order_date, Category.

First_order_date is the field that stores the customer's first ever order's date. 

I need to find customers who bought products from Category X based on their First_order_date. 

I also want to append a column to my data which says "Yes" if product on first purchase was from Category X and "No" if it wasn't. 

Can Peek() function be used in this case? Can someone help me with the syntax?

Transaction data:

LOAD

Order_id, Customer_id, Product_id, Product_name,

First_order_date,

Category,

IF(Category='X' AND First_order_date  ....................................  , YesNo_Category_X= 'Yes', 'No' ) as "YesNo_Category_X)

from transactioncsv;

Any help would be greatly appreciated. Thanks a lot in advance. 

Labels (3)
2 Replies
Taoufiq_Zarra

@MK_QlikFan 

I think the sample data isn't complete. Is there any other data you'd like to share?
because in what you sent I always see if(category='X','Yes','No'), is there no date for new orders? or if you share other orders from the same customer to see what changes in row.

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Saravanan_Desingh

Can you try this? I am not sure the condition needed on First_order_date

[Transaction data]:
LOAD
Order_id, Customer_id, Product_id, Product_name,
First_order_date,
Category,
IF(Category='X', 'Yes', 'No' ) as YesNo_Category_X
from transactioncsv
;