Skip to main content
Question

PQL formula to filter activity sequences by first occurrence

  • June 23, 2023
  • 3 replies
  • 15 views

Hi there,

i've been doing some tasks for uni and stumbled across a task where i need to return 'AB' if activity A happened before B and 'BA' if B happened before A. We can assume that always exactly one of the cases is true, so no null solutions.

I tried the following PQL formula but it doesnt seem to work:

 

CASE WHEN(PU_Last("case-table", "activity-table"."ACTIVITY", "activity-table"."ACTIVITY" = 'A') < PU_Last("case-table", "activity-table"."ACTIVITY", "activity-table"."ACTIVITY" = 'B'))

THEN 'AB'

ELSE 'BA'

END

 

For some reason the first case never happens. Anyone having any ideas?

Thanks for your help and kind regards

Aaron

3 replies

  • June 23, 2023

Hi Aaron,

 

try this Formula IF A MUST BE DIRECTLY FOLLOWED by B:

 

  • CASE WHEN MATCH_PROCESS ( "Activities"."ACTIVITY" , NODE [ 'A' ] as src , NODE [ 'B' ] as trg CONNECTED BY DIRECT [ src , trg ] ) = 1 THEN 'AB' ELSE 'BA' END

If an activity A has not only to be directly followed by B but can come any time later the keyword CONNECTED BY EVENTUALLY [ src , trg ] can be used.

For more details visit this link : MATCH_PROCESS (celonis.com)


  • Author
  • Level 2
  • June 23, 2023

Hi Rashid,

thank you very much for that fast response.

The formula works like a charm!


  • June 23, 2023

Hi Rashid,

thank you very much for that fast response.

The formula works like a charm!

Hi Aaron,

I'm so glad it was helpful :)