SSRS total for time

2019-09-10 04:27发布

I have a table as such:

----------------------------------------------
Name    |     Activity     |    Activity Time
----------------------------------------------
        |                  |
        |   L030           |    07:15:00
Dan     |                  |
Smith   |------------------------------------
        |                  |
        |   L031           |    01:00:00
        |                  |
        |------------------------------------
        |   Total          |
        |                  |
---------------------------------------------
        |                  |
        |   L030           |    01:15:00
Steve   |                  |
Jones   |------------------------------------
        |                  |
        |   L031           |    06:00:00
        |                  |
        |------------------------------------
        |   Total          |
        |                  |
---------------------------------------------

The name acts as a parent group for the activities and their associated times.

I thought that it would be a simple case of using the "add total" function to generate a total amount of time, however the option is greyed out.

Is it possible to use the "add total" function with times? If not, is there a workaround which would do the same job?

Thanks

3条回答
该账号已被封号
2楼-- · 2019-09-10 04:40
=TimeSpan.FromTicks(Sum(Fields!DurationInMinutes.Value))

This should give the desired result.

查看更多
3楼-- · 2019-09-10 05:04

Thanks Wojciech Iłowiecki for putting me on the right lines.

I returned the times I wanted to present as minutes (as an integer) and used the following expression to display the correct formatted values in the box next to the individual activity:

 =FLOOR(Fields!Total_Time.Value / 60) & ":" & RIGHT("0" & (Fields!Total_Time.Value MOD 60), 2)

Of course as I used integers above, I could then use the "add total" function and formatted it using:

=FLOOR(Sum(Fields!Total_Time.Value) / 60) & ":" & RIGHT("0" & (Sum(Fields!Total_Time.Value) MOD 60), 2)

Resolved.

查看更多
等我变得足够好
4楼-- · 2019-09-10 05:05

I think it's not possbile to perform SUM on dates.

But here the workarund:

return the 'activity time' values as a integer number of minutes:

then you can format this value in RS as a time, and also perform Sum for Total:

here the example for formatting from Minutes as Integer to time format:

= (Fields!DurationInMinutes.Value/60) + ":" + (Fields!DurationInMinutes.Value - ((Fields!DurationInMinutes.Value/60) *60) +  ":00"
查看更多
登录 后发表回答