Variable grouping allows a Finished Report to change how data is grouped based on a parameter selected by the user.
For example, the same report can be grouped by EmployeeID, OrderDate, or City without creating a separate Finished Report for each grouping option.
What Is Variable Grouping?
Variable grouping uses a parameter and a calculated field together to control the report’s grouping.
The parameter provides the user with a list of grouping choices. A calculated field evaluates the selected parameter value and returns the corresponding report field.
The Finished Report is then grouped by that calculated field.
Why Use Variable Grouping?
Variable grouping is useful when you want to:
- Let users choose how report data is grouped
- Reduce the need for multiple versions of the same report
- Reuse the same Finished Report layout for different grouping options
- Give users more control over how report results are organized
Before You Begin
For this workflow:
- The grouping parameter should typically use the String datatype
- A Combobox can be used to present the grouping choices
- A calculated field is used to determine which field should be used for grouping
- The Finished Report is grouped by the calculated field rather than directly by one of the source fields
The example in this article uses these grouping options:
- EmployeeID
- OrderDate
- City
Step 1: Add a Parameter
Open the Parameters tab and select Add Parameter.
Step 2: Configure the Parameter
Configure the parameter with the settings needed for variable grouping.
For this example:
- Datatype: String
- Description: Enter a user-friendly description if needed
- Name: Enter the internal parameter name
- Type: Combobox
Step 3: Define the Parameter Values
Open the Values List and add the values that users can select.
For example:
- EmployeeID
- OrderDate
- City
Select OK after adding the values.
Step 4: Add a Calculated Field
Open Finished Reports Designer.
In the field list, right-click the applicable data source and select Add Calculated Field.
This calculated field will determine which source field is used for grouping.
Step 5: Open the Calculated Field Expression
Right-click the new calculated field and select Edit Expression.
Step 6: Create the Variable Grouping Expression
Use nested Iif() statements to map each parameter value to the field that should be used for grouping.
The general structure is:
Iif([Parameter] = 'one', Field_One,
Iif([Parameter] = 'two', Field_Two,
'else'))Each parameter value should return the corresponding grouping field.
For example:
- If the user selects EmployeeID, return the EmployeeID field
- If the user selects OrderDate, return the OrderDate field
- If the user selects City, return the City field
Note: Add another nested
Iif()condition for each additional grouping option.
Step 7: Group by the Calculated Field
Open Group and Sort.
Then:
- Select Add a Group.
- Choose the calculated field created for variable grouping.
- Configure the group as needed.
The Finished Report will now group based on the value returned by the calculated field.
Step 8: Run the Report with Different Grouping Options
Run the View and select a value for the grouping parameter.
Then open the Finished Report and confirm that the report is grouped according to the selected value.
For example:
Grouped by EmployeeID
Grouped by OrderDate
Grouped by City
Preview and Verify
Test each available parameter value and confirm that:
- The correct grouping field is used
- The report layout remains intact
- Group headers and footers display as expected
- Changing the parameter changes the grouping without requiring a separate Finished Report
Save the Report
After confirming that each grouping option works correctly, save the Finished Report.
If changes were also made to the VDM View or its parameters, save the View as well.
Comments
1 comment
I think this may need an update, there is no longer an option to right click parameters on the finished reports designer.
Please sign in to leave a comment.