Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to flag rows in script based on events?

So i got this issue, and i simply cannot figure out how to manage this.

As in my previous post i want to find the row where there has been a BUY event when there also have been an Itemclick event within the same session.

Notice: It should be in the script and not in a expression (i think its too heavy)

RowIDSessionIDPriceEventFlag
111420itemclick0
211450visit0
311490Buy1
411427Buy1
516826Buy0
616856Buy0

Hope you can help

Thanks in advance

22 Replies
Not applicable
Author

Try this code:

Table:

LOAD RowID,

     SessionID,

     Price,

     Event,

     Flag,

     if(SessionID=SessionID,if(Match(Event,'Buy','itemclick')<>0,RowID)) as Output

FROM

Book1.xlsx

(ooxml, embedded labels, table is Sheet1);

Not applicable
Author

Aint working 😕

Not applicable
Author

First click on a particular session and then check the Output. I already checked, its working fine

Not applicable
Author

Nope - It also takes sessions where there is no item.

Not applicable
Author

Thomas,

That should do it

I have created a field with 2 fields, and I do an exists() on it

Fabrice;

Not applicable
Author

Brilliant Aunez! Thank you so much. I was trying to see if i could get a table which only consisted of sessions which had a buy and itemclick. But i cannot seem to figure out how i would get a session table where it consists of session that have both itemclick and buy with same productids.

Not applicable
Author

What would you do if it should look like this?

RowIDSessionIDPriceEventProductIDFlagFlagProductBuyItemClickBuy
111420itemclick1-11
211450visit200
311490Buy230
411427Buy110
516826Buy200
616856Buy100
711423Basket400
815534itemclick1-11
915546visit100
1015546basket400
1115534itemclick2-11
1215534visit200
1315534Buy210
1415534Buy110
1515534buy330
1613334Itemclick6-10
1713334buy330
1814534Itemclick320
1914534visit300

I have tried this code:

if(upper(Event) = 'ITEMCLICK', if(exists(TempSessionBuy,SessionID),1,0)) as FlagItemBuy

but i also get 1 on those where there is a buy but they have not the same productid

Not applicable
Author

like this ?

Not applicable
Author

yep - thanks for that almost had it!

Not applicable
Author

Hi - as you can see in this excel ark - i have a new flag called FlagProductBuyLater

The flag should be 1, when the same cookieid has bought the same productid there has been an itemclick regardless of what session it is in.

So cookieid 1 has an itemclick in session 114 on productid 8 but buys it first in session 178 on same productid 8 - then that line should have 1 in flag as illustrated in the excel file.