Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Custom code error - SSRS 2008 R2

$
0
0

I am referring a tutorial at http://www.katieandemil.com/ssrs-median-function-2008-R2-custom-code-example to write a median function. Following the instructions, I can see median values from custom code are shown correctly under Report Preview. However, when i export the report into PDF/Excel format, the calculated median values turn out to be "#ERROR". Any thoughts?  Thank you!

Custom Codes

Dim valuesAs System.Collections.ArrayList

  Function AddValue(ByVal newValueAsDecimal) AsDecimal

    If (valuesIsNothing) Then

      values = New System.Collections.ArrayList()

    EndIf

    values.Add(newValue)

    AddValue = values.Count

  EndFunction

  Function GetMedian()AsDecimal

    Dim countAsInteger = values.Count

    If (count > 0)Then

      values.Sort()

      If countMod 2 = 1 Then

        GetMedian = values((count - 1) / 2)

      Else

        GetMedian = (values((count / 2) - 1) + values((count / 2))) / 2

      EndIf

    EndIf

EndFunction


Viewing all articles
Browse latest Browse all 10045

Trending Articles