Jan 19 Tommy | CodeBits

Dynamic Aging Buckets in SSRS

I was given a task of converting some aging reports to SSRS. Now as you know, you can't really do grouping in SQL based on a range. So something like that needs to be implemented in SSRS in the report writter instead. I have figured out that code for you. :)

First we need to copy this code into the report. From the report properties the first box will be for adhoc vb functions to add to the report. In general these functions should be added to a class and linked, either way this is the function you need.

Public Function GetBucket(parameter As parameter, days As Integer) As String
On Error GoTo ProcError

 Dim s As String
 Dim i As Integer
 s = ""
 
 If parameter.IsMultiValue Then
  For i = 0 To parameter.Count - 2
   If (parameter.Value(i) < days and parameter.Value(i+1) > days) Then
        GetBucket = Str(parameter.Value(i)) + " -" + Str(parameter.Value(i+1))
        Exit Function
    End If
  Next
 End If

 GetBucket = parameter.Value(parameter.Count - 1)  + "+"
 Exit Function

ProcError:
GetBucket = Err.Description
End Function

After that, we will define a calculate field in our dataset.

=Code.GetBucket(Parameters!Bucket,DateDiff("d",Fields!DateToAgeOn.Value,Today()))

 

Then set up a parameter, type integer, and allow mulitple values. Then we can just set some default values for our ranges.

Comments

Jan 24 Mella
| Link

Mella

Thank you for Another a necessity article. just where else might Anybody obtain that kind as for answer to such a complete thing on making? I have on a presentation incoming week, as well as I am at the lookout being such answer.

| Link

Leonida Donaho

It is a very good article, thanks for posting it.

Comments are closed

About

Mooglegiant.net is a site maintained by me (mooglegiant).  I occasionally put together blogengine.net themes, and random posts about tech/geek things.  If you like the site, or my work, don't forget to support me.  I'm sure you know where to click.