Author |
Message |
adders
Groupie
Joined: 09 Aug 2010
Online Status: Offline
Posts: 53
|
Topic: Split data over two weeks Posted: 24 Jul 2014 at 12:03am |
Hi,
I'm trying to create a work performance report which is going well so far. The only issue I have is the grouping. I have grouped performances by weeks which is great until I come to a job that last over a week or runs into the next week. Is there away to split the data over the 2 weeks, for example we have a job that starts on the Wednesday and ends on the following Tuesday, 30 hours completed in that time. It would be great to calculate the average, 18 hours week 1 and 12 hours week 2 and then place them into there relative groups. At the moment the groups are sorted by the start date not the finish so data is shown only in week 1 at present.
many thanks
Ads
|
IP Logged |
|
Gurbs
Senior Member
Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
|
Posted: 24 Jul 2014 at 3:28am |
Is it possible that a job runs into 3 different weeks instead of 2? For example, a job starts on Friday, and isn't finished until Monday a week later due to other priorities. Is this something that could happen?
|
IP Logged |
|
Gurbs
Senior Member
Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
|
Posted: 24 Jul 2014 at 5:05am |
If above isn't the case, I might know something - probably not the prettiest solution, the best, or god knows what else, but in my example it worked for me :)
I created 8(!) formula's (am sure you would be able to bring this down with a bit more time)
In my formula's, I am using a table called TEMP, with 2 dates, DATES as start date and DATES2 as end date, and NUMBERS as my total number of hours worked.
//Day Diff
datediff('d',{TEMP.DATES},{TEMP.DATES2})+1 -
(DateDiff ("ww",{TEMP.DATES}, {TEMP.DATES2}, CrSaturday ) +
DateDiff ("ww",{TEMP.DATES}, {TEMP.DATES2}, CrSunday ))
//Day Number
dayofweek({TEMP.DATES},crMonday)
//Week 1 Days -
if {@Day Number} = 1 then {@Day Diff} - 4 else
if {@Day Number} = 2 then {@Day Diff} - 3 else
if {@Day Number} = 3 then {@Day Diff} - 2 else
if {@Day Number} = 4 then {@Day Diff} - 1 else
if {@Day Number} = 5 then 1
//Week 2 Days
{@Day Diff} - {@Week 1 Days}
//Week Number
if datepart('ww',{TEMP.DATES},crMonday) = datepart('ww',{TEMP.DATES2},crMonday) then {TEMP.NUMBERS} else
{TEMP.NUMBERS}/{@Day Diff}*{@Week 1 Days}
//Week Number 2
if datepart('ww',{TEMP.DATES},crMonday) <> datepart('ww',{TEMP.DATES2},crMonday) then {TEMP.NUMBERS}/{@Day Diff}*{@Week 2 Days}
//Previous Week
previous({@Week Number 2})
//Previous Week 2
if not isnull({@previous week}) then previous({@Week Number 2}) + {@Week Number}
else {@Week Number}
Use the last formula (Previous Week 2) in your group header.
|
IP Logged |
|
adders
Groupie
Joined: 09 Aug 2010
Online Status: Offline
Posts: 53
|
Posted: 24 Jul 2014 at 10:01pm |
Hi Gurbs,
Thanks for the solutions, will have a play and see what i can do.
A job could indeed last more then 2 weeks but it is unlikely and certainly no more than 3 weeks.
|
IP Logged |
|
adders
Groupie
Joined: 09 Aug 2010
Online Status: Offline
Posts: 53
|
Posted: 24 Jul 2014 at 11:50pm |
So I now have the hours the job has taken. 41.02 of which 13.09 is in week 1 and the rest being in week 2, how can I tell the report to move the week 2 data into the next group or is it possible to duplicate the line and place it in the second group then perform the calculation then?
Thanks
Ads
|
IP Logged |
|
Gurbs
Senior Member
Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
|
Posted: 25 Jul 2014 at 12:05am |
The last formula takes the hours that are transferred from the week before, and add them to the current week. Or do you need the job itself to copy over?
What does your report look like?
|
IP Logged |
|
adders
Groupie
Joined: 09 Aug 2010
Online Status: Offline
Posts: 53
|
Posted: 25 Jul 2014 at 12:49am |
It would certianly be easier to copy the job over, I can take the days that are in that week of the year which it is grouped by and work it out that way. The current week I'm looking at is 16, the start time is in week 16 but the finish time is in week 17.
Thanks again.
|
IP Logged |
|
|