question

TelepathicSheep2 avatar image
TelepathicSheep2 asked

ReportBuilder 3 - Group Column by Date, using Code..

Hello all, I have dates in the date format, 2010-06-01, 2011-12-01, etc... and I'm trying to group by these in the column properties. I've adapted this code: Function GroupDates(ByVal PA_PERIOD As Integer) As String Select Case PA_PERIOD Case 1900-01-01 To 2007-12-31 GroupDates = "prior to 2008" Case 2008-01-01 To 2008-12-31 GroupDates = "2008" Case 2009-01-01 to 2009-12-31 GroupDates = "2009" Case Else GroupDates = "2010+" End Select Return GroupDates End Function I then put this in my column group properties for the PA_PERIOD field: =Code.GroupDates(Fields!PA_PERIOD.Value) ... I'm not sure why it doesn't work - but this is the error I get: The Group expression for the grouping ‘PA_PERIOD’ contains an error: Input string was not in a correct format. (rsRuntimeErrorInExpression) ---------------------------- An error has occurred during report processing. (rsProcessingAborted) I tried to troubleshoot - I removed the select case statement and put GroupDates = "2010" for example, just to see if it would group everything under one label, but I get the same error... anybody have any suggestions/know what's going on? Thanks in Advance, Sheep
reporting
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Doug Lane avatar image
Doug Lane answered
Your function expects an integer, which 1900-01-01 is not. Try this instead: Function GroupDates(ByVal PA_PERIOD As String) As String
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

TelepathicSheep2 avatar image
TelepathicSheep2 answered
Thanks Doug, I was able to run it now - no more error, however there is only one grouping, 2011-06-01 which happens to be the last month that I have data for... any ideas why that would be?
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Doug Lane avatar image Doug Lane commented ·
Make sure your column groups by the same expression: "=Code.GroupDates(Fields!PA_PERIOD.Value)". If you've got your group properties set up right, you'll see the custom groupings from your function used by the tablix.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.