Business Calendar: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
No edit summary
(32 intermediate revisions by the same user not shown)
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. time, which can be used in the duration calculation to get durations which only covers the working time (instead of 24 hour per day). Each model can have its own business calendar and in addition, business calendars can be defined when writing expressions. In dimensions and measures calculating durations, there is a '''Use business calendar''' checkbox determining whether durations are calculated 24 hour per day or using the business calendar of the model.


== Business Calendar Object ==
== Defining Business Calendar ==
In the expression language, a business calendar is created using the '''BusinessCalendar''' function which takes the calendar definition as the following structure:
Business calendar can be defined for a model as follows: Open the models list, click the menu for a model and select '''Business calendar'''. In the dialog, the ''Weekly Business Time'' tab allows to define the weekly schedule where each row is a period within a day. Note that the weekly schedule periods must not overlap each other.
 
The ''Holidays'' tab allows to define days, when there is exceptionally no business hours. If you need to set the ending time to a midnight, use value 12:00 AM / 00:00 (i.e. same as the day begin time). If there is a need for a period that spans to multiple days, define them as separate rows where the previous ends at midnight and the next period starts at the beginning of the day.
 
== Using Business Calendars in Expressions ==
In the expression language, a business calendar is created with the '''BusinessCalendar''' function using the following calendar definition:
<pre>
<pre>
BusinessCalendar(#{
BusinessCalendar(#{
   "weeklyWorkingHours": [
   "WeeklyWorkingHours": [
     #{ "weekDay": 1, "startHour": 8, "endHour": 16 },
     #{ "WeekDay": 1, "StartHour": 8, "EndHour": 16 },
     #{ "weekDay": 2, "startHour": 8, "endHour": 11 },
     #{ "WeekDay": 2, "StartHour": 8, "EndHour": 11 },
     #{ "weekDay": 2, "startHour": 12, "endHour": 17 },
     #{ "WeekDay": 2, "StartHour": 12, "EndHour": 17 },
     #{ "weekDay": 3, "startHour": 8, "endHour": 16 },
     #{ "WeekDay": 3, "StartHour": 8, "EndHour": 16 },
     #{ "weekDay": 4, "startHour": 8, "endHour": 16 },
     #{ "WeekDay": 4, "StartHour": 8, "EndHour": 16 },
     #{ "weekDay": 5, "startHour": 8, "endHour": 15 }
     #{ "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" ]
   "ExceptionDays": [ "2020-12-06", "2020-12-24", "2020-12-25", "2020-12-26", "2021-01-01", "2021-01-06" ]
})
})
</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, because they are not defined in the calendar.
This 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:
* '''weeklyWorkingHours''': Defines the weekly working calendar. The items in the array are individual working periods within each day. There can be several working periods in the same weekday. 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.
* '''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.
* '''ExceptionDays''': List of dates, when there is exceptionally no 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.


== Duration Calculation ==
== Calculating Duration between Timestamps ==
Durations can be calculated by using the '''timeDiff''' function in the business calendar as follows:
Durations based on the business calendar are calculated by using the '''TimeDiff''' function that is available in the Business Calendar object:
<pre>
let calendar = BusinessCalendar(#{...});
let duration1 = calendar.timeDiff(date1, date2);
</pre>
 
Example:
<pre>
<pre>
let calendar = BusinessCalendar(#{
let calendar = BusinessCalendar(#{
   "weeklyWorkingHours": [
   "WeeklyWorkingHours": [
     #{ "weekDay": 1, "startHour": 8, "endHour": 16 },
     #{ "WeekDay": 1, "StartHour": 8, "EndHour": 16 },
     #{ "weekDay": 2, "startHour": 8, "endHour": 11 },
     #{ "WeekDay": 2, "StartHour": 8, "EndHour": 11 },
     #{ "weekDay": 2, "startHour": 12, "endHour": 17 }
     #{ "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" ]
   "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));
calendar.timeDiff(DateTime(2020, 12, 1), DateTime(2021, 1, 1));
</pre>
</pre>
== Duration Calculation in Process Mining Objects ==
[[Process_Mining_Objects_in_Expression_Language|Process mining objects]] have the following properties and functions available for duration calculation:
{| class="wikitable"
!'''Object type'''
! '''24/7 durations'''
! '''Business calendar durations'''
|-
||Case
||
* Duration property
* DurationBetweenEvents function
||
* Duration(businessCalendar) function
* DurationBetweenEvents function (5. parameter)
|-
||Flow
||
* AverageDuration property
* MedianDuration property
* DurationStandardDeviation property
||
* AverageDuration(BusinessCalendar) function
* MedianDuration(BusinessCalendar) function
* DurationStandardDeviation(BusinessCalendar) function
|-
||FlowOccurrence
||
* Duration property
||
* Duration(BusinessCalendar) function
|}


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

Revision as of 22:56, 20 February 2021

The business calendar defines a weekly calendar for working/office/factory/etc. time, which can be used in the duration calculation to get durations which only covers the working time (instead of 24 hour per day). Each model can have its own business calendar and in addition, business calendars can be defined when writing expressions. In dimensions and measures calculating durations, there is a Use business calendar checkbox determining whether durations are calculated 24 hour per day or using the business calendar of the model.

Defining Business Calendar

Business calendar can be defined for a model as follows: Open the models list, click the menu for a model and select Business calendar. In the dialog, the Weekly Business Time tab allows to define the weekly schedule where each row is a period within a day. Note that the weekly schedule periods must not overlap each other.

The Holidays tab allows to define days, when there is exceptionally no business hours. If you need to set the ending time to a midnight, use value 12:00 AM / 00:00 (i.e. same as the day begin time). If there is a need for a period that spans to multiple days, define them as separate rows where the previous ends at midnight and the next period starts at the beginning of the day.

Using Business Calendars in Expressions

In the expression language, a business calendar is created with the BusinessCalendar function using the following calendar definition:

BusinessCalendar(#{
  "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" ]
})

This 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:

  • 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: List of dates, when there is exceptionally no 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.

Calculating Duration between Timestamps

Durations based on the business calendar are calculated by using the TimeDiff function that is available in the Business Calendar object:

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" ]
})
calendar.timeDiff(DateTime(2020, 12, 1), DateTime(2021, 1, 1));

Duration Calculation in Process Mining Objects

Process mining objects have the following properties and functions available for duration calculation:

Object type 24/7 durations Business calendar durations
Case
  • Duration property
  • DurationBetweenEvents function
  • Duration(businessCalendar) function
  • DurationBetweenEvents function (5. parameter)
Flow
  • AverageDuration property
  • MedianDuration property
  • DurationStandardDeviation property
  • AverageDuration(BusinessCalendar) function
  • MedianDuration(BusinessCalendar) function
  • DurationStandardDeviation(BusinessCalendar) function
FlowOccurrence
  • Duration property
  • Duration(BusinessCalendar) function