Business Calendar: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
The business calendar defines a weekly calendar for e.g. working/office/factory hours, which is used in the duration calculations to determine the duration where only the working hours have been taken into account (instead of 24h/days).
The business calendar defines a weekly calendar for working/office/factory/etc. hours, which is used in the duration calculations to determine durations where only the working hours have been taken into account (instead of 24 hour per days). Business calendar can be defined for each model, and also new business calendars can be defined when writing custom expressions. In dimensions and measures related to durations, you can set whether durations are calculated 24 hour per days or using the business calendar of the model.


== Business Calendar Object ==
== Business Calendar Object ==
Line 18: Line 18:
</pre>
</pre>


The previous example defines the following weekly schedule: Monday 8-16, Tuesday 8-11 and 12-17, Wednesday 8-16, Thursday 8-16 and Friday 8-15. Note that there is no working time in Saturday and Sunday, as they are not defined in the calendar.
The previous example defines the following weekly schedule: Monday 8-16, Tuesday 8-11 and 12-17, Wednesday 8-16, Thursday 8-16 and Friday 8-15. There is no working time in Saturday and Sunday, as they are not defined in the example calendar.


The structure in the business calendar initialization has the following properties:
The structure in the business calendar initialization has the following properties:
Line 26: Line 26:


== Duration Calculation ==
== Duration Calculation ==
Durations using the business calendar are calculated by using the '''TimeDiff''' function of the business calendar as follows:
Durations based on the business calendar are calculated by using the '''TimeDiff''' function (available in the Business Calendar object) as follows:
<pre>
<pre>
let calendar = BusinessCalendar(#{...});
let calendar = BusinessCalendar(#{...});
let duration1 = calendar.TimeDiff(date1, date2);
let duration1 = calendar.TimeDiff(date1, date2);
</pre>
</pre>
 
In this example, replace the ''#{...}'' with the actual business calendar definition. Example:
Example:
<pre>
<pre>
let calendar = BusinessCalendar(#{
let calendar = BusinessCalendar(#{
Line 44: Line 43:
let duration1 = calendar.timeDiff(DateTime(2020, 12, 1), DateTime(2021, 1, 1));
let duration1 = calendar.timeDiff(DateTime(2020, 12, 1), DateTime(2021, 1, 1));
</pre>
</pre>
== Duration Calculation in EventLog Objects ==
EventLog related objects have the following properties and function available for duration calculations:
{| class="wikitable"
!'''Object'''
! '''24 hours per day durations'''
! '''Business calendar based durations'''
|-
||Case
||Duration property
||Duration(businessCalendar) function
|-
||Flow
||Duration property
||Duration(businessCalendar) function
|-
||FlowOccurency
||
* AverageDuration property
* MedianDuration property
* DurationStandardDeviation property
||
* AverageDuration(businessCalendar) function
* MedianDuration(businessCalendar) function
* DurationStandardDeviation(businessCalendar) function
|}


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

Revision as of 14:12, 14 December 2020

The business calendar defines a weekly calendar for working/office/factory/etc. hours, which is used in the duration calculations to determine durations where only the working hours have been taken into account (instead of 24 hour per days). Business calendar can be defined for each model, and also new business calendars can be defined when writing custom expressions. In dimensions and measures related to durations, you can set whether durations are calculated 24 hour per days or using the business calendar of the model.

Business Calendar Object

In the expression language, a business calendar is created using the BusinessCalendar function which takes the calendar definition as the following structure:

BusinessCalendar(#{
  "Name": "My calendar",
  "WeeklyWorkingHours": [
    #{ "WeekDay": 1, "StartHour": 8, "EndHour": 16 },
    #{ "WeekDay": 2, "StartHour": 8, "EndHour": 11 },
    #{ "WeekDay": 2, "StartHour": 12, "EndHour": 17 },
    #{ "WeekDay": 3, "StartHour": 8, "EndHour": 16 },
    #{ "WeekDay": 4, "StartHour": 8, "EndHour": 16 },
    #{ "WeekDay": 5, "StartHour": 8, "EndHour": 15 }
  ],
  "ExceptionDays": [ "2020-12-06", "2020-12-24", "2020-12-25", "2020-12-26", "2021-01-01", "2021-01-06" ]
})

The previous example defines the following weekly schedule: Monday 8-16, Tuesday 8-11 and 12-17, Wednesday 8-16, Thursday 8-16 and Friday 8-15. There is no working time in Saturday and Sunday, as they are not defined in the example calendar.

The structure in the business calendar initialization has the following properties:

  • Name: Optional name for the calendar. Name is usually not needed when initializing the calendar in expression. When multiple calendars are defined for a model, the calendars are identified by the name.
  • WeeklyWorkingHours: Defines the weekly working calendar. The items in the array are individual working periods. One working period can span only within the same day. There can be several working periods in the same day. The WeekDay is defined as a number between 0 (Sunday) and 6 (Saturday). The StartHour and EndHour needs to be between 0 and 24. If no weekly schedule is defined, 24h/days calendar is assumed.
  • ExceptionDays: All the dates, when there is not working time, e.g. holidays. Exception days are defined as a string array where each day is defined using format yyyy-MM-dd. Defining exception days is not mandatory for in the business calendar.

Duration Calculation

Durations based on the business calendar are calculated by using the TimeDiff function (available in the Business Calendar object) as follows:

let calendar = BusinessCalendar(#{...});
let duration1 = calendar.TimeDiff(date1, date2);

In this example, replace the #{...} with the actual business calendar definition. Example:

let calendar = BusinessCalendar(#{
  "WeeklyWorkingHours": [
    #{ "WeekDay": 1, "StartHour": 8, "EndHour": 16 },
    #{ "WeekDay": 2, "StartHour": 8, "EndHour": 11 },
    #{ "WeekDay": 2, "StartHour": 12, "EndHour": 17 }
  ],
  "ExceptionDays": [ "2020-12-06", "2020-12-24", "2020-12-25", "2020-12-26", "2021-01-01", "2021-01-06" ]
})
let duration1 = calendar.timeDiff(DateTime(2020, 12, 1), DateTime(2021, 1, 1));

Duration Calculation in EventLog Objects

EventLog related objects have the following properties and function available for duration calculations:

Object 24 hours per day durations Business calendar based durations
Case Duration property Duration(businessCalendar) function
Flow Duration property Duration(businessCalendar) function
FlowOccurency
  • AverageDuration property
  • MedianDuration property
  • DurationStandardDeviation property
  • AverageDuration(businessCalendar) function
  • MedianDuration(businessCalendar) function
  • DurationStandardDeviation(businessCalendar) function