all groups > sql server reporting services > may 2007 >
You're in the

sql server reporting services

group:

Addtion / Sum of Parameter Array Values - SSRS


Addtion / Sum of Parameter Array Values - SSRS nlulla
5/14/2007 10:02:36 AM
sql server reporting services:
Hi All,

I want to Sum instead of Join Parameter arrays selected values and use
it within the report to display data based on total sum of all the
values selected. Join concatanates them with comma delimited values
but i want sum of all those values.

Example as below
Value DisplayText
1 - Current Month
2 - Previoius Year
4 - Half Year
8 - Year to date

so if
current month and half year
are selected then i want to read 1 + 4 = 5 and not 1,4 as currently i
get by join function.

Code = SUM(Parameters!dropdownbox.value)
Result = #Error

Code = Join(Parameters!dropdownbox.value,",")
Result = "1,4"

Code = SUM(Join(Parameters!dropdownbox.value,","))
Result = #Error

Code = Parameters!dropdownbox.count
Result = 4 (it gives me length of array)

Code = ?
Result = 5 (This is the result is want...but can make it work)



Any help greatly appreciated

Regards
Nirav Lulla
Yotta Consulting
Re: Addtion / Sum of Parameter Array Values - SSRS james_hatt NO[at]SPAM cable.comcast.com
5/21/2007 11:25:58 AM
[quoted text, click to view]


I'm not sure how many items are in your dropdown list but this will
work if you only have a few...

=CInt(Parameters!site.Value(0)) + CInt(Parameters!site.Value(1))

Re: Addtion / Sum of Parameter Array Values - SSRS nlulla
5/31/2007 3:12:38 AM
Hi James,

Thanks for posting your reply, you suggesstio would only work if i
have set fixed length of options, but i don't know how this is going
to work in case of unknown number of options.
For now , I have Created a .net class file DLL with following code and
referenced the dll in my .rdl file, it works for me, but would be good
if it can be done within SSRS itself. Any more suggesstions welcome

Nirav Lulla
Yotta Consulting


Public Class ClsCommon
Const bDisplayColumn As Boolean = False
Const bHideColumn As Boolean = True
Shared Function SumOfArrayString(ByVal ArrayString As String) As
Integer
Dim arylist As System.Array
Dim sum As Integer

Try
arylist = ArrayString.Split(",")
For Each item As Integer In arylist
sum += CInt(item)
Next
Catch ex As Exception
Return -1
Finally
Return sum
End Try
End Function
End Class
AddThis Social Bookmark Button