Source/Target is the function you need to use to solve your problem. However, the good news is you should be able to use it as when I checked the documentation its tagged as being available for Celonis 4.3. I suspect the misunderstanding comes for the fact that it isn’t currently listed in the PQL reference list visible in Celonis itself. I would recommend reading up on SOURCE/TARGET operations in PQL documentation (found by opening the Celonis help page and searching for SOURCE/TARGET) as they are useful for a wide range of use cases like this one.
Before launching into a step by step guide of how to build the overview of 'activity-neighbours’ I will try to briefly explain how it works.
The SOURCE / TARGET operations where developed to enable calculations to be made on the relationship between activities to be made on an activity level rather than a case one, this is particularly important for activities that can take place multiple times.
To use them you create a table with dimensions which define the source (first activity) and the target (second activity). Source and Target include an option to define how they relate to each other; the default is for the source to be the activity immediately precede the target activity. When you add a KPI like ‘average throughput time between activities’ activities are only used in the calculation if have the relationship specified in Source and Target. I.e for the row containing the activities ‘A’ and ‘B’ the calculation of the average throughput time would only use time -stamps of a particular pair of ‘A’ and ‘B’, belonging to the same case, if ‘A’ is immediately followed by ‘B’.
Here is how to apply SOURCE / TARGET to your particular use case:
- Create a button dropdown to select the Activity coded to the variable X.
Note: it’s important that the wrapping characters are single quotation marks (’)
- Create an OLAP table with the following two dimensions:
2.1 SOURCE ( "ACTIVITIES"."ACTIVITY" )
2.2 TARGET ( "ACTIVITIES"."ACTIVITY" )
- Add a KPI which counts the occurrences of the target activity directly following the source activity (this is not the same thing as case count as activities (and there for connections) can happen multiple times in one case).
Code: COUNT ( TARGET ( "ACTIVITIES"."ACTIVITY" ))
(If case count really is what you want then I would suggest using this code instead to avoid the same case being counted twice:
COUNT(DISTINCT SOURCE("ACTIVITIES"."CASE_KEY")) )
Make a copy the table. Name one something like "Activities directly before <%= X %>" and the other "Activities directly before <%= X %>"
To make the tables only display the relevant combinations of activities, add the filter “FILTER TARGET ( “ACTIVITIES”.“ACTIVITY” ) = <%= X %>” to the ‘before’ table and “FILTER SOURCE ( “ACTIVITIES”.“ACTIVITY” ) = <%= X %>” to the ‘after’ table.
(Optional) To make the tables tidier you can hide the ‘target’ dimension in the ‘before’ table and the ‘source’ dimension in the ‘after’ table so you don’t have columns of the same activity name.
I hope this answers your question, if not feel free to write back.
Calandra (Celonis Data Science Team)