The last feature this article will demonstrate is how to use
the parameter panel to change how a report is group at runtime. By allowing
the user to change groups at runtime they can see summations, counts, and
averages based on the groups without having to create separate reports for each
group.
1.
Stop the debugger if it is running. Right click on the Parameter fields
in the Field Explorer and select New…
2.
Enter "Group By" for the name of the formula.
3.
In the Value Grid enter "City", "State\Province",
and "Hire Date (Year)".
4.
In the Value Options grid, change the Allow Custom Values setting to
false.
5.
Click the OK button.
6.
Right click on the Formula Fields in the Field Explorer and select New…
from the pop-up menu.
7.
Enter "Grouping Field" for the name and click the OK button.
8.
Enter the following formula:
if {?Group By} = "City" then
{Address.City}
else if {?Group By} = "State\Province" then
{StateProvince.StateProvinceCode}
else if {?Group By} = "Hire Date (Year)" then
totext(Year({Employee.HireDate}), "####")
9.
This will resolve what the user has entered into the correct database
field or formula.
10. Click
the Save and close button.
11. Now
you need to add a group that groups by this formula. Right click on the white
space in the report and select InsertàGroup
from the pop-up menu.
12. Set
the condition field to the "Grouping Field" formula and click the OK
button.
13. The
group should now be added to the report and a group header and footer section
should appear in the design of the report.
14. Now
add a count to the group header. When you preview the report and change how
the grouping works this number should change.
15. Right
click on the Last Name field in the Details section.
16. Select
InsertàSummary from the pop-up menu.
17. Change
the "Calculate This Summary" drop down list to "Count".
18. Change
the "Summary Location" drop down list to "Group #1:GroupingField
- A".
19. Click
the OK button. This will add the count to the group footer section. Drag the
field to the group header section.
20. Run
the report again. This time enter a start date of 1/1/2000 and an end date of
12/31/2001. Set the grouping field to City. Your report should look like the
following image.
21. Display
the Parameter Panel by clicking on the (?) on the left side. Change the group
to Hire Date (Year) and click the Apply button.
The report should now be displayed grouped by the year of
the employee's hire date.