Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Average wait time

Author  Topic 

MikaSa
Starting Member

7 Posts

Posted - 2012-03-22 : 18:17:01
I have a column that with an expression that shows the to number of minutes a person waited from time of arrival to time waited on using datediff.
I would like to take the average amount of wait time for returned results and display in the header.
I am having trouble with the expression to average the returned results from a query.
I would typically have five or more rows returned when the query is run.
Any help would be appreciated?

Thanks

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-22 : 19:46:20
Is this in T-SQL or in SSRS? In either case, there is an Avg function that will calculate the average for you.
Go to Top of Page

MikaSa
Starting Member

7 Posts

Posted - 2012-03-22 : 19:57:53
It's in ssrs. I am fairly new to srs and can't seem to grt the expression to work
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-22 : 20:04:49
I assume you have looked at this page and examples there: http://msdn.microsoft.com/en-us/library/ms159806(v=sql.100).aspx

If that doesn't help you, can you post the expression that you want to get the average of?
Go to Top of Page

MikaSa
Starting Member

7 Posts

Posted - 2012-03-23 : 09:54:32
quote:
Originally posted by sunitabeck

I assume you have looked at this page and examples there: http://msdn.microsoft.com/en-us/library/ms159806(v=sql.100).aspx

If that doesn't help you, can you post the expression that you want to get the average of?


I looked at the page but it wasn't what I was looking for. The expression I am trying to average is

DateDiff("n",Fields!ARRIVAL_TIME.Value,Fields!VENIPUNTURE_TIME.Value)
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-23 : 10:19:06
quote:
Originally posted by MikaSa

I looked at the page but it wasn't what I was looking for. The expression I am trying to average is

DateDiff("n",Fields!ARRIVAL_TIME.Value,Fields!VENIPUNTURE_TIME.Value)

Doesn't this work?
Avg(DateDiff("n",Fields!ARRIVAL_TIME.Value,Fields!VENIPUNTURE_TIME.Value))
You may need to provide the dataset name as shown in the examples on the link that I posted earlier.
Go to Top of Page

MikaSa
Starting Member

7 Posts

Posted - 2012-03-23 : 13:06:57
The problem seems to be that I trying to use this expression in the header
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-23 : 21:06:13
Not sure if being in the header will cause any problems, but first try it somewhere where it is in scope and see if that works. If it does, move it outside and include the dataset as the second parameter and see if that works.
Go to Top of Page

MikaSa
Starting Member

7 Posts

Posted - 2012-03-24 : 08:20:36
What I ended up doing is creating a new row above and outside. put my expression in a cell and hid the row. I then placed a text in the headrer with the expression ReportItems!Textbox25.value
It worked.
Go to Top of Page
   

- Advertisement -