Group Expression Examples (Report Builder 3.0)
In a data region, you can group data by a single field, or create more complex expressions that identify the data on which to group. Complex expressions include references to multiple fields or parameters, conditional statements, or custom code. When you define a group for a data region, you add these expressions to the Group properties. For more information, see How to: Add or Delete a Group in a Data Region (Report Builder 3.0).
To merge two or more groups that are based on simple field expressions, add each field to the group expressions list in the group definition.
The following table provides examples of group expressions that you can use to define a group.
Group by the Region field.
Group by last name and first name.
Group by the first letter of the last name.
Group by parameter, based on user selection.
In this example, the parameter GroupBy must be based on an available values list that provides a valid choice to group on.
Group by three separate age ranges:
"Under 21", "Between 21 and 50", and "Over 50".
=IIF(First(Fields!Age.Value)<21,"Under 21",(IIF(First(Fields!Age.Value)>=21 AND First(Fields!Age.Value)<=50,"Between 21 and 50","Over 50")))
Group by many age ranges. This example shows custom code, written in Visual Basic .NET, that returns a string for the following ranges:
25 or Under
26 to 50
51 to 75
Function GetRangeValueByAge(ByVal age As Integer) As String
Select Case age
Case 0 To 25
GetRangeValueByByAge = "25 or Under"
Case 26 To 50
GetRangeValueByByAge = "26 to 50"
Case 51 to 75
GetRangeValueByByAge = "51 to 75"
GetRangeValueByByAge = "Over 75"
For more information about custom code, see Using Custom Code References in Expressions (Report Builder 3.0).