Schedule Adherence report
2 posters
Page 1 of 1
Schedule Adherence report
I have 2 transaction fact tables. First one contains an activity key, employee key, start timestamp, and end timestamp that reflects a schedule. I have the same structure that contains the actual activities and timestamps worked. I am struggling with creating a single SQL statement to produce an adherence report.
As it was described to me, Adherence is the number of minutes that Actual perfectly overlaps Schedule. Am I oversimplifying in thinking this can be done in 1 SQL SELECT statement?
As it was described to me, Adherence is the number of minutes that Actual perfectly overlaps Schedule. Am I oversimplifying in thinking this can be done in 1 SQL SELECT statement?
TheNJDevil- Posts : 68
Join date : 2011-03-01
Re: Schedule Adherence report
Something like this? I assume here that the grain is activity * employee for both fact tables.
select activity, employee max(scheduledstart), max(scheduledend), max(actualstart), max(actualend) from --you can then add and subtract these as necessary to calculate the adherence.
(Select activity, employee, scheduledstart, scheduledEnd, null, null
ScheduleFact + dimensions
union
select activity, employee, null, null, actualstart, actualend
ActualFact + dimensions ) a
group by activity, employee
nathanjones77- Posts : 11
Join date : 2014-06-03
Location : Zurich
Re: Schedule Adherence report
Breaking down each possible variation, I came up with the following. It seems to work to find the activity time range that falls between the scheduled time range.
a is the activity table, s is the schedule table, STIME is start timestamp, ETIME is end timestamp
- Code:
CASE WHEN (a.ETIME>=s.STIME And a.STIME<=s.ETIME)
THEN DateDiff(Minute, a.STIME,a.ETIME) - CASE WHEN (a.STIME<s.STIME)
THEN DateDiff(Minute, a.STIME,s.STIME)
ELSE 0 END
- CASE WHEN (a.ETIME>s.ETIME)
THEN DateDiff(Minute, s.ETIME,a.ETIME)
ELSE 0 END
ELSE 0 END AS 'MinutesAdherence'
a is the activity table, s is the schedule table, STIME is start timestamp, ETIME is end timestamp
TheNJDevil- Posts : 68
Join date : 2011-03-01
Similar topics
» Modelling a payment schedule
» View for each report
» Report requirement has the following ...
» Cognos 8 Report studio SQL problem
» Report filtering on Facts
» View for each report
» Report requirement has the following ...
» Cognos 8 Report studio SQL problem
» Report filtering on Facts
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum