Recently I came across a challenging issue with calculating a time span within a group inside an SSRS Report. I am working on an issue where I need to be able to calculate labor pace operations per hour, and the time a person works on a particular labor task. My report data looks like the following:
As you can see, this person submitted their first weight at 7:34 AM with a weight of 13.805 lbs. In SSRS, it’s fairly straightforward to have a total for the weight, however, a total for the shift proved to be a little more challenging. I was hoping I could simply use the SUM() function in hopes that SSRS would know how to handle the time format and just give me a total time. No such luck. Through a series of trials and errors with the TimeSpan function, I realized that I could use the Min() and Max() functions with a simple math equation. Ultimately, my formula wound up being the following:
when applying the function, it yielded the a total of:
My next challenge was formatting the total so that it could be used in an equation with the total weight in order to determine my average lbs per hour. After several hours of trial and error with various TimeSpan and DateDiff/DatePart functions, I found simple was best and ended with this formula to get my results:
this got me an average of 34.58 lbs/hr and was able to use the formula throughout the report.