SSRS total for time

为君一笑 提交于 2020-01-25 02:44:39

问题


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


回答1:


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"



回答2:


=TimeSpan.FromTicks(Sum(Fields!DurationInMinutes.Value))

This should give the desired result.




回答3:


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.



来源:https://stackoverflow.com/questions/17699490/ssrs-total-for-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!