Hi @HMJason,
You could use two expressions in your Tags_preprocessing
table to achieve this.
In the first expression (Unique_consecutive_activities_per_case
), you can extract only the unique consecutive activities by making a lookup by Case ID
in the Events_preprocessing
table, setting the level to Case ID
, sorting the records level on Event_order
, and writing the expression like this:
listtojson(filter(records, prev.Activity <> Activity).Activity)
Afterwards, you can write another expression (A is directly followed by B is directly followed by C
) for computing a tag for cases that have activity A directly followed by B and then by C, only looking at unique occurrences of those activities. This would be a per record expression with this logic:
// set variables for activity names for convenience purposes
// you can make these constants in your globals table
var activityA := "a";
var activityB := "b";
var activityC := "c";
// get the list of unique consecutive activities
var activities := jsontolist(Unique_consecutive_activities_per_case);
// calculate the max length of the list of unique activites per record
var maxIndex := count(activities);
// check if A is followed by B
var activityAIsFollowedByB :=
ifnull(indexof(activityB, activities), maxIndex) - ifnull(indexof(activityA, activities), maxIndex) = 1;
// check if B is followed C
var activityBIsFollowedByC :=
ifnull(indexof(activityC, activities), maxIndex) - ifnull(indexof(activityB, activities), maxIndex) = 1;
// finally, combine the two checks
activityAIsFollowedByB and activityBIsFollowedByC
The way this works is that it looks in the list of unique consecutive activities (the first expression you made) and checks that A and B, as well as B and C, are apart from one another by only one index in the list for each case in your data.
Finally, you can add this tag in your Tags_filter
as you would with any other tag