- Introduction
- Understanding the Value of Parameters
- Creating and Implementing Parameters Fields
- Using Parameters with Record Selections
- Using Parameters with Top/Bottom N Group Selections
- Creating and Implementing Dynamic and Cascading Parameters
- Troubleshooting
- Crystal Reports in the Real WorldCustom Filtering
Creating and Implementing Dynamic and Cascading Parameters
New to version XI, Crystal Reports now provides the ability for report parameters to be based on dynamic values derived directly from a database or from the BusinessObjects Enterprise repository (if using BusinessObjects Enterprise). This new functionality enables end users to select from the most recent list of elements dynamically retrieved from the database at run time.
An additional new powerful feature provided in version XI is the ability to link these dynamic parameters together in a cascading manner. These cascading parameters enable end users to select parameter values by entering information at multiple levels, with all levels leading to dynamic filters being applied to all subsequent level parameters. The most common example of this is where a City parameter might be filtered based on the linked Country parameter as described earlier in the chapter. Specifically, if Canada is the only country selected, only cities in Canada are available for selection in the linked City parameter. These dynamic, cascading parameters are set through the same Create Parameter dialog used for static parameters.
The following steps will take you through a practical example of the creation and implementation of a dynamic, cascading set of prompts:
- Open the sample Chap5 report or the one you have previously created in this chapter, and after removing the Country record selection and the Top N Value formula, delete the existing Countries parameter.
- Create a new Parameter called Cities with type String and select the Dynamic List of Values type.
- Ensuring the New radio button is selected, click on the Value field of the parameters table and you are prompted with a drop-down list box where the Country field from the Customer table is selected.
- Ensure the Allows Multiple Values property is set to True and the Allows Custom Values property is set to False. You have now created Country as the highest level parameter of this group.
- Now click on the Value field in the next row of the parameters table and you will be prompted with a drop-down list where you select the City field from the Customer table. Ensure the Allows Multiple Values property is set to True and the Allows Custom Values property is set to False. You have now created City as the second and currently lowest-level parameter of this group.
- To complete the parameter creation process, click on the Parameters fields for each of the Country and City rows in the parameter table. The prompting text of Click to Create a Parameter changes to the specific parameter name consisting of the top level parameter name suffixed by the involved field name. Figure 5.13 highlights what this should look like.
Figure 5.13 The Create/Edit Parameter dialog enables rapid creation of dynamic and cascading parameters.
- Now add a new record selection through the Record Select Expert that filters the report where the City field from the customer table is equal to the newly created parameter {?Cities – City}.
- Finally, refresh the report and you are faced with the parameter selection screen shown in Figure 5.13. Note that as you add countries to the list of countries selected in the Cities parameter group, the list of available cities in the City parameter is dynamically filtered. After testing the filtering process, select USA, Canada, and Ireland as countries with only Las Vegas, Philadelphia, Vancouver, Toronto, and Dublin as selected cities. Click OK and your report resembles something similar to Figure 5.14.
Figure 5.14 The new dynamic and cascading parameter feature enables increased productivity in report design and a better end-user experience.
This new powerful cascading parameter feature enables increased end-user productivity through reduced and focused selection sets. When designing reports, careful consideration should be given to use of these dynamic and cascading parameters versus the static parameters. Dynamic parameters are ideally geared for data sets that change frequently. Static parameters might be best used when the involved list of values does not change often because no additional database hits will be required.