Functions for aggregating values across all events within the same case.
Understanding Case Aggregates
In process mining, a case represents a single instance of a process (e.g., one order, one ticket, one customer journey). Each case contains multiple events (the individual steps or activities).
Case aggregate functions calculate values across all events in a case, making the result available at each event. This allows you to:
- Calculate total values for a case (e.g., total order amount)
- Find patterns within cases (e.g., count of rework events)
- Compare individual events to case-level statistics
Common Patterns
-
Calculate Case Totals:
caseSum(ItemAmount) // Total order value
caseCount() // Number of events in case
caseCountDistinct(Resource) // Unique resources involved
-
Find Extremes:
caseMin(Timestamp) // First event time
caseMax(Timestamp) // Last event time
caseMax(Timestamp) - caseMin(Timestamp) // Total case duration
-
Conditional Aggregates:
caseCountIf(Status == "Error") // Error count
caseSumIf(Amount, Activity == "Payment") // Total payments
caseAvgIf(Duration, Activity == "Review") // Avg review time
-
Compare Event to Case:
Duration / caseAvg(Duration) // Is this event faster/slower than average?
caseSum
(attribute) Sums a numeric attribute across all events in the current case.
| Parameters | | attribute | number | The attribute to sum | |
| Returns | number |
| Examples | caseSum(ItemAmount) → Total of all ItemAmount values in the case |
caseAvg
(attribute) Calculates the average of a numeric attribute across all events in the current case.
| Parameters | | attribute | number | The attribute to average | |
| Returns | number |
| Examples | caseAvg(ProcessingTime) → Average processing time per event |
caseMin
(attribute) Returns the minimum value of an attribute across all events in the current case.
| Parameters | | attribute | number | The attribute whose minimum you want | |
| Returns | number |
| Examples | caseMin(ItemPrice) → Lowest price in the case |
caseMax
(attribute) Returns the maximum value of an attribute across all events in the current case.
| Parameters | | attribute | number | The attribute whose maximum you want | |
| Returns | number |
| Examples | caseMax(ItemPrice) → Highest price in the case |
caseCount
() Returns the number of events in the current case.
| Returns | number |
| Examples | caseCount() → Number of events in the case |
caseMedian
(attribute) Returns the median value of an attribute across all events in the current case.
| Parameters | | attribute | number | The attribute whose median you want | |
| Returns | number |
| Examples | caseMedian(Duration) → Middle value of Duration in the case |
caseCountDistinct
(attribute) Counts the distinct values of an attribute in the current case.
| Parameters | | attribute | any | The attribute whose distinct values you want to count | |
| Returns | number |
| Examples | caseCountDistinct(Resource) → Number of unique resources in the case |
caseStdDev
(expr) Calculates the standard deviation across events in the case.
| Parameters | | expr | number | Value expression | |
| Returns | number |
| Examples | caseStdDev(Amount) → Standard deviation within the case |
caseSumIf
(attribute, condition) Sums values only for events that match a condition.
| Parameters | | attribute | number | The attribute to sum | | condition | boolean | The condition to filter by | |
| Returns | number |
| Examples | caseSumIf(Amount, Status == "Approved") → Sum of Amount where Status is Approved |
caseAvgIf
(attribute, condition) Averages values only for events that match a condition.
| Parameters | | attribute | number | The attribute to average | | condition | boolean | The condition to filter by | |
| Returns | number |
| Examples | caseAvgIf(Duration, Activity == "Review") → Average duration of Review activities |
caseCountIf
(condition) Counts events that match a condition in the current case.
| Parameters | | condition | boolean | The condition to count | |
| Returns | number |
| Examples | caseCountIf(Status == "Error") → Number of error events in the case |
caseMinIf
(attribute, condition) Returns the minimum value for events that match a condition.
| Parameters | | attribute | number | The attribute whose minimum you want | | condition | boolean | The condition to filter by | |
| Returns | number |
| Examples | caseMinIf(Timestamp, Activity == "Start") → Timestamp of first Start activity |
caseMaxIf
(attribute, condition) Returns the maximum value for events that match a condition.
| Parameters | | attribute | number | The attribute whose maximum you want | | condition | boolean | The condition to filter by | |
| Returns | number |
| Examples | caseMaxIf(Timestamp, Activity == "End") → Timestamp of last End activity |
Running Aggregates
Running aggregates calculate cumulative values up to and including the current event. As you move through the events in a case chronologically, the running value updates.
This is useful for:
- Tracking cumulative totals (running sum)
- Identifying event position (running count)
- Calculating rolling averages
Running Aggregate Patterns
-
Cumulative Totals: Track how a value accumulates over the case:
caseRunningSum(ItemAmount) // Cumulative order total at each event
| Event | Amount | caseRunningSum(Amount) |
| 1 | 100 | 100 |
| 2 | 50 | 150 |
| 3 | 75 | 225 |
-
Event Position: Identify where an event falls in the case sequence:
caseRunningCount() // 1, 2, 3, 4...
-
Rolling Average: Calculate the average up to the current point:
caseRunningAvg(Duration) // Average duration so far
-
Position-Based Logic:
if(caseRunningCount() == 1, "First",
if(caseRunningCount() == caseCount(), "Last", "Middle")
)
caseRunningSum
(attribute) Calculates the cumulative sum through the current event, including that event.
| Parameters | | attribute | number | The attribute to sum | |
| Returns | number |
| Examples | caseRunningSum(ItemAmount) → Cumulative total at each event |
caseRunningCount
() Returns the event number within the case, starting at 1.
| Returns | number |
| Examples | caseRunningCount() → Event position: 1, 2, 3, ... |
caseRunningAvg
(attribute) Calculates the cumulative average through the current event, including that event.
| Parameters | | attribute | number | The attribute to average | |
| Returns | number |
| Examples | caseRunningAvg(Duration) → Average duration up to this point |
caseRunningMin
(expr) Calculates the running minimum through the current event.
| Parameters | | expr | number | Value expression | |
| Returns | number |
| Examples | caseRunningMin(Amount) → Running minimum amount |
caseRunningMax
(expr) Calculates the running maximum through the current event.
| Parameters | | expr | number | Value expression | |
| Returns | number |
| Examples | caseRunningMax(Amount) → Running maximum amount |
Statistical Functions
Statistical functions for analyzing the distribution of values within a case.
-
Percentiles: Find where a value falls relative to others in the case. Pass the percentile as a fraction from 0 to 1, so 0.9 means the 90th percentile:
casePercentile(Duration, 0.5) // Median duration in this case
casePercentile(Duration, 0.9) // 90th percentile
-
Variance: Measure how spread out values are:
caseVariance(Amount) // Variation within this case
casePercentile
(attribute, percentile) Calculates an attribute's percentile value within the current case.
| Parameters | | attribute | number | The attribute to analyze | | percentile | number | The percentile as a fraction from 0 to 1 (0.9 = 90th percentile) | |
| Returns | number |
| Examples | casePercentile(Duration, 0.9) → 90th percentile duration in the case |
caseVariance
(attribute) Calculates an attribute's variance within the current case.
| Parameters | | attribute | number | The attribute to analyze | |
| Returns | number |
| Examples | caseVariance(ProcessingTime) → Variance of processing times in the case |