KPIs are calculated by calling the KpiCalculateAndPersist_v94 Business Component method (see KPI Calculation Component). This approach allows KPIs to be calculated according to a schedule (e.g., by a job running within the Job Scheduler framework) or on-demand from within a Standard Operation, a process, or anywhere else in DELMIA Apriso where a Business Component can be invoked.
The flow chart below describes the steps involved in calculating a KPI:
As the figure illustrates, the process starts with executing the context query. The program exits if no records are returned. The “from” and “to” times for a KPI are calculated for each row returned by the context SQL, since they are frequently dependent on the data elements contained in the returned row.
For example, the KPI could have a TimeFrom term defined as ResourceStartTime, which finds the first time a machine was turned on and uses that time. This time will be different for each resource.
Understanding KPI Term calculations involves a discussion of input parameter substitution. As indicated earlier, KPI Terms are linked to either Business Components or directly to Stored Procedures. Both scenarios can involve one or more inputs and return a single numeric output.
The base framework of the Performance Dashboard takes each named input for a particular KPI Term and substitutes a value from the set of rows returned after executing the context statement against the database. This is done for every named input except for TimeFrom and TimeTo, which are substituted in from the TimeFrom and TimeTo calculations discussed earlier.
For example, for a KPI Term linked to a Stored Procedure called CalculateResourceUpTime and with the following inputs:
and with the following KPI Context Query:
SELECT ResourceName, ResourceType
From Resource_
where ResourceType = 6 –type equipment
the following rows will be returned:
ResourceName |
ResourceType |
Grinder1 |
6 |
Grinder2 |
6 |
The term will be calculated twice for each row returned in the context statement.
Row 1 will be called CalculateResourceUpTime (Grinder1, 6) and Performance Dashboard will calculate the entire KPI for this record. After this is completed, it gets the next row and CalculateResourceUpTime will be called with the next row inputs (Grinder2, 6).
After each KPI Term is calculated, the overall KPI value is calculated according to the expression defined in the KPI properties screen (see Properties). It is persisted to the database for real-time retrieval by one or more operational users. As shown in Tree, KPIs are stored in the KPI_VALUE table, which in turn is linked to a fact in one of the FACT tables (Production, Order, etc.). This keeps the KPI value and history table generic and independent of specific context requirements.
The KPI calculation entity is stored in the key values of the KPI data. The columns Key1 – Key10 in KPI_VALUE are used to store the attributes relevant to the calculated value. The data from the context query is stored in the key value columns as defined in the KPI configuration.
There are two KPIs in two different grids:
The context query would need to be referenced differently in both:
SELECT
Facility,
WorkCenter
FROM
WORK_CENTER
The Facility and Work Center will be mapped from each of the context queries
So if the result of the context query is:
Then the KPI result table will look something like this:
Key1 |
Key2 |
Value_ |
Tempe |
Assembly 1 |
1003 |
Tempe |
Cutting Center |
1044 |
Tempe |
Drilling Center |
604 |
Tempe |
Grinding Center |
734 |
SELECT
Facility
FROM
WORK_CENTER
Key1 |
Value_ |
C1P1 |
43 |
C1P2 |
22 |
C1P3 |
21 |
Chrlt |
7 |
The KpiCalculateAndPersist_v94 method in the KpiController BC is used to calculate KPIs. Its detailed description is provided in the Business Components Documentation.
The KPI Context Query is executed to retrieve the KPI calculation entities. If the start time and/or end time is provided, then that is used in the KPI calculation; otherwise, the start time and end time are determined from the time expressions or time terms. In the case of time terms, the time value is calculated for each record returned by the context query.
The terms defined in the KPI Expressions are evaluated by passing the required input values to the configured term evaluator. The expression is then calculated using the term values.
If a KPI_VALUE record exists for the key values, then the calculated KPI value is updated; otherwise, a new record is inserted. The KPI value history and term history are inserted for each record based on the settings of the inputs AddKpiHistory and AddTermHistory.