On This Page

Case Aggregate Functions

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 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 Attribute to average
Returns number
Examples
caseAvg(ProcessingTime) → Average processing time per event

caseMin

(attribute)

Returns the minimum attribute value across all events in the current case.

Parameters
attribute number Attribute whose minimum to return
Returns number
Examples
caseMin(ItemPrice) → Lowest price in the case

caseMax

(attribute)

Returns the maximum attribute value across all events in the current case.

Parameters
attribute number Attribute whose maximum to return
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 attribute value across all events in the current case.

Parameters
attribute number Attribute whose median to return
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 Attribute whose distinct values 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 meet a condition.

Parameters
attribute number Attribute to sum
condition boolean 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 meet a condition.

Parameters
attribute number Attribute to average
condition boolean Condition to filter by
Returns number
Examples
caseAvgIf(Duration, Activity == "Review") → Average duration of Review activities

caseCountIf

(condition)

Counts events in the current case that meet a condition.

Parameters
condition boolean Condition to count
Returns number
Examples
caseCountIf(Status == "Error") → Number of error events in the case

caseMinIf

(attribute, condition)

Returns the minimum value among events that meet a condition.

Parameters
attribute number Attribute whose minimum to return
condition boolean Condition to filter by
Returns number
Examples
caseMinIf(Timestamp, Activity == "Start") → Timestamp of first Start activity

caseMaxIf

(attribute, condition)

Returns the maximum value among events that meet a condition.

Parameters
attribute number Attribute whose maximum to return
condition boolean 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 and including the current event.

Parameters
attribute number Attribute to sum
Returns number
Examples
caseRunningSum(ItemAmount) → Cumulative total at each event

caseRunningCount

()

Returns the event number in the case, starting at 1.

Returns number
Examples
caseRunningCount() → Event position: 1, 2, 3, ...

caseRunningAvg

(attribute)

Calculates the cumulative average through and including the current event.

Parameters
attribute number 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 within the current case.

Parameters
attribute number Attribute to analyze
percentile number 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 Attribute to analyze
Returns number
Examples
caseVariance(ProcessingTime) → Variance of processing times in the case

Design better processes. Build a connected architecture. Stay in control.

Get instant access with no credit card and no waiting. Turn the way your organization works into clear, connected process designs.

Build your process architecture, define ownership and controls, and align roles and responsibilities across every level.

Start your free trial and create one reliable foundation for governing, managing, and continuously improving your processes.