SAP Reports 2011, WIN, INTL, NUL 7090310 User Manual

Product codes
7090310
Page of 706
21.12.11.1 To add dynamic grouping using parameter fields
1.
Create a report using the sample data, Xtreme.mdb, and place the following fields from left to right
in the Details section:
{Customer.Customer Name}
{Customer.Country}
{Orders.Order ID}
{Orders.Order Date}
{Orders.Order Amount}
2.
Create a new parameter field and call it GroupBy.
3.
Select String from the Type list.
4.
Add the following values to your parameter:
Customer
Country
Order
5.
Select Editable from the Show on (Viewer) Panel list, and click OK.
6.
Create a new formula field and call it GroupField.
7.
Type the following formula into the Formula text box.
If {?GroupBy} = 'Customer' then
{Customer.Customer Name}
Else if {?GroupBy} = 'Country' then
{Customer.Country}
Else if {?GroupBy} = 'Order' then
ToText({Orders.Order ID})
Note:
Crystal Reports formulas do not allow conditions to return different data types. Both the Customer
Name and Country fields return strings, so the ToText function must be used to convert the Order
ID from a number to a string as well.
8.
Save your formula and close the Formula Workshop.
9.
In the Group Expert, select the GroupField formula as your group field, and click OK.
10.
Customize summary fields and section formatting as you like.
Users can now change the grouping presentation of the report by modifying the GroupBy parameter
value on the Parameter Panel.
Note:
Changing parameter values will not cause a database refresh as long as the parameter is a non-data
parameter.
Related Topics
2011-05-16
490
Parameter Fields and Prompts