Showing posts with label expression. Show all posts
Showing posts with label expression. Show all posts

Thursday, March 22, 2012

Can't seem to round an average.

I am using an expression to create an average. The result is an odd number like 33.666666666666667.

I want to round this to 34 (I would even accept 33, or 33.67), just not so manny digits to the right.

Hello Patrick,

Try this in your expression:

=Round(Avg(Fields!Number.Value), 2)

The 2 in my example is how many digits to include.

Hope this helps.

Jarret

sql

Tuesday, March 20, 2012

Can''t see function for code added in Report Properties

I put a function in the code section of Report Properties. I went to add an expression and can't find the function. I type =code. and did not see the function I created in the list.

Here's my code below:

Code Snippet

Public Function ConvertToStartDate(ByVal StartDate As String) As DateTime
Select Case StartDate
Case "Today"
Return DateTime.Today
Case "Yesterday"
Return DateTime.Today.AddDays(-1)
Case "30DaysOut"
Return DateTime.Today.AddDays(+30)
Case "2DaysPrior"
Return DateTime.Today.AddDays(-2)
' Additional cases
Case Else
Throw New ArgumentException("Unknown argument, " & StartDate, "StartDate")
End Select
End Function

I should be able to put in expression =code.ConvertToStartDate.StartDate("Today"), but that does not work. I get a red squiggly line under StartDate.

Thanks for your help,

Iris

from your code snippet up above, you would use:

=Code.ConvertToStartDate("Today")

I havent had the intellisense work on custom function code.

BobP

|||

Works like a charm....Thanks!

Iris

Can''t see function for code added in Report Properties

I put a function in the code section of Report Properties. I went to add an expression and can't find the function. I type =code. and did not see the function I created in the list.

Here's my code below:

Code Snippet

Public Function ConvertToStartDate(ByVal StartDate As String) As DateTime
Select Case StartDate
Case "Today"
Return DateTime.Today
Case "Yesterday"
Return DateTime.Today.AddDays(-1)
Case "30DaysOut"
Return DateTime.Today.AddDays(+30)
Case "2DaysPrior"
Return DateTime.Today.AddDays(-2)
' Additional cases
Case Else
Throw New ArgumentException("Unknown argument, " & StartDate, "StartDate")
End Select
End Function

I should be able to put in expression =code.ConvertToStartDate.StartDate("Today"), but that does not work. I get a red squiggly line under StartDate.

Thanks for your help,

Iris

from your code snippet up above, you would use:

=Code.ConvertToStartDate("Today")

I havent had the intellisense work on custom function code.

BobP

|||

Works like a charm....Thanks!

Iris

Can''t see function for code added in Report Properties

I put a function in the code section of Report Properties. I went to add an expression and can't find the function. I type =code. and did not see the function I created in the list.

Here's my code below:

Code Snippet

Public Function ConvertToStartDate(ByVal StartDate As String) As DateTime
Select Case StartDate
Case "Today"
Return DateTime.Today
Case "Yesterday"
Return DateTime.Today.AddDays(-1)
Case "30DaysOut"
Return DateTime.Today.AddDays(+30)
Case "2DaysPrior"
Return DateTime.Today.AddDays(-2)
' Additional cases
Case Else
Throw New ArgumentException("Unknown argument, " & StartDate, "StartDate")
End Select
End Function

I should be able to put in expression =code.ConvertToStartDate.StartDate("Today"), but that does not work. I get a red squiggly line under StartDate.

Thanks for your help,

Iris

from your code snippet up above, you would use:

=Code.ConvertToStartDate("Today")

I havent had the intellisense work on custom function code.

BobP

|||

Works like a charm....Thanks!

Iris

sql