Skip to main content
Announcements
Save $600 on Qlik Connect registration! Sign up by Dec. 6 to get an extra $100 off with code CYBERSAVE: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
charu16aug
Contributor III
Contributor III

How to create flag if ID and date is same as 'Purchase ' and Repurchase

TabA:
Load * Inline
[
ID,Purchase_Date,Purchase,item
1,27/03/2022,500,charger
2,28/05/2022,700,mobile
2,28/05/2022,100,charger
1,27/03/2022,600,mobile
1,29/03/2022,300,laptop
3,30/01/2022,400,camera

];

 

Here's the sample data-

i want if the ID and date is repeating same for that ID then it should create new flag as 'Purchaser'

and if that ID is purchasing on different date then 'Repurchase'

ex-D,Purchase_Date,Purchase,item,flag
1,27/03/2022,500,charger,Repurchase
2,28/05/2022,700,mobile,Purchase
2,28/05/2022,100,charger,Purchase
1,27/03/2022,600,mobile,Repurchase
1,29/03/2022,300,laptop,Repurchase
3,30/01/2022,400,camera,Purchase

Labels (1)
1 Solution

Accepted Solutions
Saravanan_Desingh

Try this,

TabA:
Load RowNo() As RowID,* Inline
[
ID,Purchase_Date,Purchase,item
1,27/03/2022,500,charger
2,28/05/2022,700,mobile
2,28/05/2022,100,charger
1,27/03/2022,600,mobile
1,29/03/2022,300,laptop
3,30/01/2022,400,camera
];

Left Join(TabA)
LOAD ID, If(Count(DISTINCT Purchase_Date)>1,'Repurchase','Purchase') As flag
Resident TabA
Group By ID;

commQV04.png

View solution in original post

1 Reply
Saravanan_Desingh

Try this,

TabA:
Load RowNo() As RowID,* Inline
[
ID,Purchase_Date,Purchase,item
1,27/03/2022,500,charger
2,28/05/2022,700,mobile
2,28/05/2022,100,charger
1,27/03/2022,600,mobile
1,29/03/2022,300,laptop
3,30/01/2022,400,camera
];

Left Join(TabA)
LOAD ID, If(Count(DISTINCT Purchase_Date)>1,'Repurchase','Purchase') As flag
Resident TabA
Group By ID;

commQV04.png