Filtering in QPR ProcessAnalyzer Queries
QPR ProcessAnalyzer queries to the models can be filtered to include or exclude the selected cases, events or objects to the calculation. Queries have the parameter Filter to pass a filter definition. The Root cause analysis has also the parameter Comparison which divides the analyzed data into two groups to compare them in the analysis. The Comparison parameter has the same structure as in the Filter parameter.
If a filter (or comparison) refers to non-existing data (e.g. event type names or case attribute values), the non-existing values are simply ignored. Still, if the CaseAttributeValue or EventAttributeValue filter refers to an attribute name that doesn't exist, an error is given.
Case-centric filter rules
Overview
The filter definition for a case-centric model has syntax demonstrated by the following example:
{ "Items": [ { "Type": "IncludeCases", "Items": [ { "Type": "EventType", "Values": ["Sales Order Created", "Payment Received"] }, { "Type": "CaseAttributeValue", "Attribute": "Region", "Values": ["Dallas", "Austin"] } ] }, { "Type": "ExcludeCases", "Items": [ { "Type": "Case", "Values": ["Case1", "Case2", "Case3"] }, { "Type": "flow", "Values": [ { "From": "Shipment", "To": "Invoice" } ] } ] } ] }
The outmost object has a property Items which is an array of object with following properties:
- Type: Specifies the type of the filtering operation with following options:
- IncludeCases / ExcludeCases: Includes / excludes cases. All filter rule types can be used with this option.
- IncludeEvents / ExcludeEvents: Includes / excludes events. Only Attribute filter rule types can be used with this option.
- IncludeEventTypes / ExcludeEventTypes: Includes / excludes events based on the event type. Only Event type and Expression filter rule types can be used with this option.
- Disabled: (boolean) Defines whether the filter rule is applied or not. This is used by the UI to temporarily disable filter rule without removing them.
The following chapters list different filter rule types that can be used in the above defined Items property.
Expression
Filter rule type ExpressionValue (for in-memory calculation) or SqlExpressionValue (for dataframe calculation) selects cases or events that match the given expression. There is property Configuration which has properties:
- Root: The root expression returning objects that are used to evaluate the Expressions (see below). If not defined, all the cases in the current event log are used as root objects. The root expression should return following types of objects: (1) for case filters: cases, events, event types, flows or flow occurrences, (2) for event filters: events and (3) for event type filters: event types. The expressions are typically what can be used as chart dimension expressions.
- Expressions: Array of expressions specifying the filter rules. There is the AND logic between the filter rules, so all expressions need to match for the objects to come to the filter. Properties:
- Expression: When filter rule type is ExpressionValue, specifies an eventlog based expression that is evaluated for each root object. When filter rule type is SqlExpressionValue, specifies an SQL expression that is evaluated for each root object.
- Values: Array of values to match to the expression result. Suitable only for strings, numeric and boolean values.
- StringifiedValues: Array of values to match to the expression result, and the values are defined in the stringified format. This has a better support for different data types than in the Values property.
- NumberPrecision: Similar setting as the expression analysis dimensions have to round numerical type of result of the expression.
- DatetimeTruncation: Similar setting as the expression analysis dimensions have to round date type of result of the expression.
- TimespanPrecision: Similar setting as the expression analysis dimensions have to round timespan type of result of the expression. Supported only for expression type ExpressionValue.
- Comparison: Defines type of comparison operation among the following: equal (default), notequal, greaterthan, lessthan, greaterthanorequal and lessthanorequal. When comparison is equal or notequal, several values can be specified. For other comparison types, there must only be one value. The lower and greater than comparisons work with numbers, datatimes and timespans. In the lower and greater than comparisons, null values in both sides of the comparison result in a non-match. Rounding or truncation defined by the NumberPrecision, DateTimeTruncation or TimespanPrecision are done before comparison, so do not use them if comparison should be based on the original values.
- Columns: For SqlExpressionValue type, additional calculated columns that can be used in the main expression. Defined as an array of objects with following properties:
- Name: Column name.
- Expression: Column expression. In the expression, it's possible to refer to the previous columns.
- Variables: Object specifying key-value pairs, where each pair creates a variable into the expression context where key is the name of the variable and value is its value. The values will be converted to strings. Supported only for expression type ExpressionValue.
Examples:
Select cases named "case1" and "case2".
{ "Type": "ExpressionValue", "Configuration": { "Root": "Cases", "Expressions": [ { "Expression": "Name", "Values": ["case1", "case2"] } ] } }
Cases where duration is as rounded 3 or 4 days.
{ "Type": "ExpressionValue", "Configuration": { "Root": "Cases", "Expressions": [ { "Expression": "Duration.TotalDays", "NumberPrecision": 0, "StringifiedValues": ["43", "44"] } ] } }
Cases where duration is as rounded 3 or 4 days.
{ "Type": "ExpressionValue", "Configuration": { "Root": "Cases", "Expressions": [ { "Expression": "Duration", "TimespanPrecision": "day", "StringifiedValues": ["73.00:00:00.000", "74.00:00:00.000"] } ] } }
Cases that have started in October or November 2020.
{ "Type": "ExpressionValue", "Configuration": { "Root": "Cases", "Expressions": [ { "Expression": "StartTime", "DatetimeTruncation": "month", "StringifiedValues": ["22020-10-01T00:00:00.000", "22020-11-01T00:00:00.000"] } ] } }
Selects cases whose duration is longer than one day.
{ "Type": "ExpressionValue", "Configuration": { "Root": "Cases.Where(Duration.TotalDays > 1)" } }
Same as previous using the Comparison property:
{ "Type": "ExpressionValue", "Configuration": { "Root": "Cases", "Expressions": [ { "Expression": "Duration.TotalDays", "Comparison": "greaterthan", "Values": [1] } ] } }
All Cases that have started before year 2020:
{ "Type": "ExpressionValue", "Configuration": { "Root": "Cases", "Expressions": [ { "Expression": "StartTime", "Comparison": "lessthan", "StringifiedValues": ["22020-01-01T00:00:00.000"] } ] } }
Returns all cases that are conformant with the specified BPNM model.
{ "Type": "ExpressionValue", "Configuration": { "Variables": { "bpmnXml": "<XML BPMN model>" }, "Root": "Let(\"myConformanceModel\", DesignModelFromXml(bpmnXml));Cases.Where(IsConformant(myConformanceModel));" } }
Pass date values as ticks and convert them into date objects (that are used in the actual comparison).
{ "Type": "ExpressionValue", "Configuration": { "Root": "Cases", "Expressions": [ { "Expression": "myDatetimeAttribute", "ValueConversionExpression": "_.DateTimeFromTicks(_)", "Values": [636214968000000000, 636239160000000000, 636291828000000000] } ] } }
{ "Type": "SqlExpressionValue", "Configuration": { "Root": "Cases", "Expressions": [{ "Expression": "AggregateFrom(Events, \"Count\")", "Values": [4,5] }] } }
Attribute
Filter rule type Attribute selects events having given event attribute values. This filter rule is available only when processing method is DataFrame, and when filter operation type is IncludeEvents/ExcludeEvents. Properties:
- Attribute: Event attribute name.
- Values: Array of event attribute values. Suitable only for string, integer and boolean values.
- StringifiedValues: Array of event attribute values in the stringified format. Better support for different data types. Note that due to the equality comparison, float values cannot be used.
Examples:
{ "Type": "Attribute", "Attribute": "Role", "Values": ["Consultant", "Sales", "Support"] }
{ "Type": "Attribute", "Attribute": "Automation", "StringifiedValues": ["0Manual"] }
Case attribute value
Filter rule type CaseAttributeValue selects cases having given value in given case attribute. Properties:
- Attribute: Case attribute name.
- Values: Array of case attribute values. Suitable only for string, integer and boolean values.
- StringifiedValues: Array of case attribute values in the stringified format. Better support for different data types. Note that due to the equality comparison, float values cannot be used.
Example:
{ "Type": "CaseAttributeValue", "Attribute": "Region", "Values": ["Dallas", "Austin", "New York"] }
{ "Type": "CaseAttributeValue", "Attribute": "Region", "StringifiedValues": ["0Dallas", "0Austin", "0New York"] }
Event attribute value
Filter rule type EventAttributeValue selects cases having events with given event attribute values. Properties:
- Attribute: Name of the event attribute.
- Values: An array of event attribute values. Suitable only for string, integer and boolean values.
- StringifiedValues: Array of event attribute values in the stringified format. Better support for different data types. Note that due to the equality comparison, float values cannot be used.
Example:
{ "Type": "EventAttributeValue", "Attribute": "Organization", "Values": ["Organization 1", "Organization 2"] }
{ "Type": "EventAttributeValue", "Attribute": "Organization", "StringifiedValues": ["0Organization 1", "0Organization 2"] }
Event type
Filter rule type EventType selects cases containing selected event types (Type=IncludeCases/ExcludeCases) or selects event types (Type=IncludeEventTypes/ExcludeEventTypes). It has property Values which is an array of event type names.
Example:
{ "Type": "EventType", "Values": ["Sales Order Created", "Payment Received", "Delivery Sent"] }
Variation
Filter rule type Variation selects cases belonging to specific variations. There are the following properties:
- Paths: Array of variations where each variation is a string array of event type names.
- SourceData: Defines which event attribute represents event types. If not specified, the event type mapping of the model or the query is used. This setting can be used to filter variations from any event attribute point of view, such as persons.
Examples:
{ "Type": "Variation", "Paths": [ ["Activity 1", "Activity 2", "Activity 3"], ["Activity 3"], ["Activity 2", "Activity 4"] ] }
{ "Type": "Variation", "Paths": [ ["John", "Patricia", "John"] ], "SourceData": { "Events": { "Columns": { "EventType": "User" } } } }
Flow
Filter rule type Flow selects cases going through the defined flow(s). There are the the following properties:
- Flows: Array of objects defining the selected flows. There are the following properties:
- From: Event type name of the flow start. null if the flow is the starting flow.
- To: Event type name of the flow end. null if the flow is the ending flow.
- Occurrence: Zero-based occurrence index of the selected flow within its case. If not specified, represents all occurrences.
- SourceData: Defines which event attribute represents event types. If not specified, the event type mapping of the model or the query is used. This setting can be used to filter flows from any event attribute point of view, such as persons. Only supported in Snowflake.
Examples:
{ "Type": "Flow", "Flows": [{ "From": "EventType1", "To": "EventType2", "Occurrence": 1 }] }
{ "Type": "Flow", "Flows": [{ "From": null, "To": "EventType1" }, { "From": null, "To": "EventType2" }] }
{ "Type": "Flow", "Flows": [{ "From": "John", "To": "Patricia" }], "SourceData": { "Events": { "Columns": { "EventType": "User" } } } }
Case ID
Filter rule type Case selects individual cases. It supports property Values which is an array of case ID's which can be either strings or integers.
Examples:
{ "Type": "Case", "Values": ["case1", "case2", "case3"] }
{ "Type": "Case", "Values": [123, 456] }
Object-centric filter rules
Object-centric filter rules filter object-centric models. Filter and perpective calculations are applied in the following order:
- Object-centric filter rules are applied and as a result, there is an object-centric eventlog with lower number of objects and events.
- Perspective is applied, and the result is a case-centric eventlog.
- Case-centric filter rules are applied similar to a normal case-centric model.
Filtering with object attributes
Object-centric models can be filtered with object attribute value filter rule. As a result, there are all the objects where the object attribute criteria matches and all other types of objects when following the object-to-object relations (according to the RecursionDepth parameter).
Supported properties:
- Include (boolean): If true, only the entities matching the filter will be included into the result. If false, only the entities that do not match the filter will be included into the result. Default value is true.
- Disabled (boolean): Whether the filter rule is enabled (false) or disabled (true). Default value is false. Disabled filter rules are ignored in the calculation.
- ObjectAttributeValue (object): Object. Contains parameters for an object attributes filter rule.
- ObjectType (string): A string value specifying the object type name based on which the filtering is applied.
- Attribute (string): A string name of the attribute whose value is to be filtered. Same as the name of the column in object type's datatable.
- RecursionDepth (integer): An integer value specifying how many traversals of all the object-to-object relations are to be performed for the objects having the matching attribute value in order to find the final set of objects to matching the filter. Default value is empty which will traverse all available relations.
- Values (string array): An array of strings specifying the values to search in the stringified format.
The following example shows the filter json definition:
{ "OcelItems": [ { "Include": true, "Disabled": false, "ObjectAttributeValue": { "ObjectType": "Purchase Order", "Attribute": "Product", "RecursionDepth": 2, "Values": [ "0Cow", "0Cat", "0Dog" ] } }, { "Include": false, "ObjectAttributeValue": { "ObjectType": "Delivery", "Attribute": "Method", "Values": [ "0Collection" ] } } ] }
Filtering based on case-centric filter rules
Object-centric models can be filtered with an object-centric filter rules that are based on a case-centric filter rule. The logic is that a perspective (which is defined as part of the filter rule) is used to map the filtered cases or events in the case-centric eventlog back to the object-centric model.
Following properties are supported:
- Include (boolean): If true, only the entities matching the filter will be included into the result. If false, only the entities that do not match the filter will be included into the result. Default value is true.
- Disabled (boolean): Whether the filter rule is enabled (false) or disabled (true). Default value is false. Disabled filter rules are ignored in the calculation.
- CaseCentric (object): Object. Contains following parameters:
- FilterTarget: Defines which type of case-centric entities the filter rule is filtering. Available values are Cases, Events, and EventTypes.
- ObjectType (string): String value specifying the object type name for the perspective.
- EventTypes (string array): String array specifying the event type names for the perspective.
- RecursionDepth (integer): Integer value specifying how many traversals of all the object-to-object relations are to be performed for the objects having the matching attribute value in order to find the final set of objects to matching the filter. Default value is empty which will traverse all available relations.
- <CaseCentricFilterRuleProperties>: Any case-centric filter rule properties can be added defining the case-centric filter rule.
Examples:
{ "OcelItems": [ { "CaseCentric": { "ObjectType": "Employees", "FilterTarget": "Cases" "Type": "CaseAttributeValue", "Attribute": "Role", "StringifiedValues": [ "0Shipment" ] } } ] }
{ "OcelItems": [ { "CaseCentric": { "ObjectType": "Packages", "FilterTarget": "Cases", "Type": "EventType", "Values": [ "Failed delivery" ] } } ] }
{ "OcelItems": [ { "CaseCentric": { "ObjectType": "Packages", "FilterTarget": "Events", "Type": "EventType", "Values": [ "Failed delivery" ] } } ] }
{ "OcelItems": [ { "CaseCentric": { "ObjectType": "Packages", "FilterTarget": "Cases", "Type": "Flow", "Flows": [ { "From": "Create package", "To": "Package delivered" } ] } } ] }
{ "OcelItems": [ { "CaseCentric": { "ObjectType": "Employees", "FilterTarget": "Cases" "Type": "SqlExpressionValue", "Configuration": { "Root": "Cases", "Expressions": [ { "Expression": "DurationBetweenDates(\"day\", AggregateFrom(Events, \"Min\", TimeStamp), AggregateFrom(Events, \"Max\", TimeStamp))", "Comparison": "greaterthan", "StringifiedValues": [ "120" ] } ] } } } ] }