Calculated Attributes in QPR ProcessAnalyzer: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
No edit summary
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
Calculated attributes enable to create case and event attributes using an expression (calculation formula) based on data in the QPR ProcessAnalyzer model. Calculated attributes can be modified and Model properties dialog.
Calculated attributes enable to create case and event attributes using a expressions (calculation formula) based on data in the QPR ProcessAnalyzer model. Calculated attributes can be modified and Model attributes dialog that can be opened in the models list in the header. Note that when calculated attributes are changed, the model is dropped from the memory, so that the changed attributes can be recalculated (reloading large models might take time).


== Introduction and Usecases==
== Setting calculated attributes ==
Data to '''case attributes''' and '''event attributes''' can be originated as follows:
Calculated case and event attributes are set for each model separately in the '''Model attributes''' dialog that can be opened in the models list in the header. The dialog has '''Case attributes''' and '''Event attributes''' tabs, where each contain an ordered list of case/event attributes. Each attribute has a name, and in addition it should be defined how the attribute value is calculated. There is a list of ready made selections (same as the dimensions list in the [[QPR_ProcessAnalyzer_Chart#Measures.2C_Dimensions_and_Columns|chart settings]], and additionally a custom expression can be written for the calculated attribute. It's possible to convert a ready-made selection into a custom expression by selecting '''Custom expression''' from the list, e.g. to modify the ready-made selection.
 
== Functioning principle and use cases ==
 
Data to case attributes and event attributes can be originated as follows:
* '''Import''' them into QPR ProcessAnalyzer from a source system, csv file etc.
* '''Import''' them into QPR ProcessAnalyzer from a source system, csv file etc.
* '''Calculate''' attribute values when the model is loaded using an [[QPR ProcessAnalyzer Expressions|expression]].
* '''Calculate''' attribute values when the model is loaded using an [[QPR ProcessAnalyzer Expressions|expression]].


Calculated attributes have following use cases:
* Conversions: If an imported attribute data is not in a suitable format, the data can be overridden by defining a calculated attribute with the same name. The calculated attribute expression performs conversions for the data.
* Aggregations: It's possible to aggregate e.g. event level information to case level using a calculated case attribute.
* Performance: If there is an expression to aggregate event level information to a case level, the aggregation can be done already in the model loading using a calculated case attribute for better performance.
== Functioning Principle ==
Calculated attributes work as follows:
Calculated attributes work as follows:
* After the model is loaded, the calculated and imported attributes work similarly, e.g. both are available in the profiling and influence analyses.
* After the model is loaded, the calculated and imported attributes work similarly, e.g. both are available in the profiling and influence analyses.
Line 21: Line 19:
* If there is an error in the calculated attribute expression, the model loading fails, and the error needs to be corrected before the model can be used.
* If there is an error in the calculated attribute expression, the model loading fails, and the error needs to be corrected before the model can be used.


Calculated case and event attributes are configured to the model JSON settings are follows:
Calculated case and event attributes are configured in the Model properties in the '''Calculated case attributes''' and '''Calculated event attributes''' tabs. The new attributes can be created, existing modified, reordered and deleted. Each attribute has '''Name''' and '''Calculation expression'''. The expression is calculated in the case's or event's context.
{| class="wikitable"
 
!'''Property'''
Calculated attributes have following use cases:
! '''Description'''
* Conversions: If an imported attribute data is not in a suitable format, the data can be overridden by defining a calculated attribute with the same name. The calculated attribute expression performs conversions for the data.
|-
* Aggregations: It's possible to aggregate e.g. event level information to case level using a calculated case attribute.
||
* Performance: If there is an expression to aggregate event level information to a case level, the aggregation can be done already in the model loading using a calculated case attribute for better performance.
CaseAttributes
 
||
== Examples of calculated case attributes ==
Array of calculated case attributes with the following properties:
 
* '''name''': Calculated attribute name. There are no restrictions for the attribute names, but avoid names starting or ending with spaces to avoid confusion.
Cost:
*'''expression''': Expression to calculate the calculated attribute. The expression is calculated in the case's or event's context. Only when an expression has been defined, the attribute is a calculated attribute.
<pre>Cost * 1.5</pre>
|-
 
||
myBooleanAttribute1:
EventAttributes
<pre>CURRENCYCODE == "RUB"</pre>
||
Calculated event attributes are defined using the same structure as calculated case attributes.
|}


== Examples ==
Combined status:
Example of calculated case attributes:
<pre>PurchaseStatus + " " + PurchaseType</pre>
* Cost: <pre>Cost * 1.5</pre>
 
* myBooleanAttribute1: <pre>CURRENCYCODE == "RUB"</pre>
Repeated Events Count:
* Combined status: <pre>PurchaseStatus + " " + PurchaseType</pre>
<pre>Count(_.Events) - Count(Distinct(_.Events.Type))</pre>
* Repeated Events Count: <pre>Count(_.Events) - Count(Distinct(_.Events.Type))</pre>
 
* Automation of first Shipment Sent: <pre>If(Count(_.EventsByType("Shipment Sent"))==0, null, (_.EventsByType("Shipment Sent").Attribute("Automation"))[0])</pre>
Automation of first Shipment Sent:
* Duration between "Invoice Sent" and "Payment Received":
<pre>If(Count(_.EventsByType("Shipment Sent"))==0, null, (_.EventsByType("Shipment Sent").Attribute("Automation"))[0])</pre>
 
Duration between "Invoice Sent" and "Payment Received":
<pre>
<pre>
If(Count(_.EventsByType("Invoice Sent")) == 0 || Count(_.EventsByType("Purchase Order Line Created")) == 0,
If(Count(_.EventsByType("Invoice Sent")) == 0 || Count(_.EventsByType("Purchase Order Line Created")) == 0,
Line 53: Line 50:
)
)
</pre>
</pre>
* KPI_SegregationOfDuties:
 
KPI_SegregationOfDuties:
<pre>
<pre>
Count(
Count(
Line 64: Line 62:
</pre>
</pre>


Example of calculated event attributes:
== Example of calculated event attributes ==
* Event Month: <pre>Timestamp.Truncate("month")</pre>
 
* Duration to Next Event: <pre>If(IsNull(_.NextInCase), null, (_.NextInCase.Timestamp-_.Timestamp))</pre>
Event Month:
* Event type occurrence number: <pre>let eventTypeName = _.Typename;Count(_.Recurse(_.PreviousInCase).Where(_.Typename==eventTypeName))</pre>
<pre>Timestamp.Truncate("month")</pre>
 
Duration to Next Event:
<pre>If(IsNull(_.NextInCase), null, (_.NextInCase.Timestamp-_.Timestamp))</pre>
 
Event type occurrence number:
<pre>let eventTypeName = _.Typename;Count(_.Recurse(_.PreviousInCase).Where(_.Typename==eventTypeName))</pre>


[[Category: QPR ProcessAnalyzer]]
[[Category: QPR ProcessAnalyzer]]

Revision as of 17:22, 10 March 2021

Calculated attributes enable to create case and event attributes using a expressions (calculation formula) based on data in the QPR ProcessAnalyzer model. Calculated attributes can be modified and Model attributes dialog that can be opened in the models list in the header. Note that when calculated attributes are changed, the model is dropped from the memory, so that the changed attributes can be recalculated (reloading large models might take time).

Setting calculated attributes

Calculated case and event attributes are set for each model separately in the Model attributes dialog that can be opened in the models list in the header. The dialog has Case attributes and Event attributes tabs, where each contain an ordered list of case/event attributes. Each attribute has a name, and in addition it should be defined how the attribute value is calculated. There is a list of ready made selections (same as the dimensions list in the chart settings, and additionally a custom expression can be written for the calculated attribute. It's possible to convert a ready-made selection into a custom expression by selecting Custom expression from the list, e.g. to modify the ready-made selection.

Functioning principle and use cases

Data to case attributes and event attributes can be originated as follows:

  • Import them into QPR ProcessAnalyzer from a source system, csv file etc.
  • Calculate attribute values when the model is loaded using an expression.

Calculated attributes work as follows:

  • After the model is loaded, the calculated and imported attributes work similarly, e.g. both are available in the profiling and influence analyses.
  • Calculated attributes are calculated when the model is loaded, and thus calculated attribute values don't change after the model loading during the time the model is in the memory. If attributes need to be calculated again, the model needs to be reloaded.
  • Calculated attribute values are stored into the memory like the imported attributes, meaning the model requires more memory, the more there are calculated attributes.
  • For calculated case attributes, the expression is evaluated in each case's context, and for calculated event attributes, for each event's context. It's thus possible to access the entire model data in the expressions, such as variations, event types, flow and flow occurrences.
  • Calculated event attributes are processed before calculated case attributes, so it's possible to use calculated event attributes in calculated case attributes expressions. Also, calculated case and event attributes are processed in the order they are defined, so it's possible to use an earlier defined calculated attribute in expressions of later attributes.
  • Calculated attribute will replace an imported attribute, if there is an imported attribute with the same name. Note that it's not possible to override event timestamp, event type name or case id.
  • If there is an error in the calculated attribute expression, the model loading fails, and the error needs to be corrected before the model can be used.

Calculated case and event attributes are configured in the Model properties in the Calculated case attributes and Calculated event attributes tabs. The new attributes can be created, existing modified, reordered and deleted. Each attribute has Name and Calculation expression. The expression is calculated in the case's or event's context.

Calculated attributes have following use cases:

  • Conversions: If an imported attribute data is not in a suitable format, the data can be overridden by defining a calculated attribute with the same name. The calculated attribute expression performs conversions for the data.
  • Aggregations: It's possible to aggregate e.g. event level information to case level using a calculated case attribute.
  • Performance: If there is an expression to aggregate event level information to a case level, the aggregation can be done already in the model loading using a calculated case attribute for better performance.

Examples of calculated case attributes

Cost:

Cost * 1.5

myBooleanAttribute1:

CURRENCYCODE == "RUB"

Combined status:

PurchaseStatus + " " + PurchaseType

Repeated Events Count:

Count(_.Events) - Count(Distinct(_.Events.Type))

Automation of first Shipment Sent:

If(Count(_.EventsByType("Shipment Sent"))==0, null, (_.EventsByType("Shipment Sent").Attribute("Automation"))[0])

Duration between "Invoice Sent" and "Payment Received":

If(Count(_.EventsByType("Invoice Sent")) == 0 || Count(_.EventsByType("Purchase Order Line Created")) == 0,
  null,
  GetAtReverse(0, _.EventsByType(["Invoice Sent", "Payment Received"])).Timestamp - GetAt(0, _.EventsByType(["Invoice Sent", "Payment Received"])).Timestamp
)

KPI_SegregationOfDuties:

Count(
  Intersect(
    _.EventsByType("Purchase Order Created").Attribute("User"),
    _.EventsByType("Purchase Order Approved").Attribute("User")
  ).
  Where(!Isnull(_) && _ != "")
) > 0

Example of calculated event attributes

Event Month:

Timestamp.Truncate("month")

Duration to Next Event:

If(IsNull(_.NextInCase), null, (_.NextInCase.Timestamp-_.Timestamp))

Event type occurrence number:

let eventTypeName = _.Typename;Count(_.Recurse(_.PreviousInCase).Where(_.Typename==eventTypeName))