I am aware of PQL that checks if activity A directly follows B. Can someone help me with PQL to check if first/last occurrence of A directly follows first/last occurrence of B?
Page 1 / 1
Hi
Not sure if I totally get what you would like to achieve, but I think you can do two checks per activity:
- Check if it is the first/last activity of that type
- Check if there is a direct follow between the two
To do, create a helping KPI:
‘KPI ‘FirstLastClassification’
CASE
WHEN INDEX_ACTIVITY_TYPE ( "activity_table"."activity_name" ) = 1
THEN 'First'
WHEN INDEX_ACTIVITY_TYPE_REVERSE ( "activity_table"."activity_name" ) = 1
THEN 'Last'
END
Then, Check if your events are true for this specific scenario:
CASE
-- perform checks on current event
WHEN "activity_table"."activity_name" = 'A'
AND KPI("FirstLastClassification") = 'First' -- Change to last if required
-- perform checks on next event
AND ACTIVITY_LEAD ( "activity_table"."activity_name" ) = 'B'
AND ACTIVITY_LEAD ( KPI("FirstLastClassification") ) = 'Last'
THEN 'Direct Follow'
ELSE NULL
END
When adding these formulas to a table, you would see for every activity if it is the first or last, and also if there is a direct follow for the situation you defined in the second KPI.
I hope this helps!
Best regards,
Jan-peter
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.