To sort a group conditionally

  1. Open or create the report that you want to sort conditionally.

    In the case of the example mentioned in this section, open or create a report that contains invoice information.

  2. In the Field Explorer, select Parameter Fields, and click New.
  3. Create a string parameter that contains the sorting options that you want your users to see.

    For this example, create a parameter called Sort Order that has two values: Ascending and Descending.

  4. Click OK to save your parameter.
  5. On the Insert menu, click Group.
  6. In the Insert Group dialog box, select the field that you want to group on.

    For this example, select your invoice date field.

  7. Select Use a Formula as Group Sort Order, and click the Conditional Formula button next to it.
  8. In the Formula Workshop, enter your conditional formula text.

    For this example, enter this text:

    If {?Sort Order} = "Ascending" then crAscendingOrder else crDescendingOrder
  9. Click Save and close to return to your report.
  10. Click OK to save your group.
  11. When you are prompted to select a Sort Order, select the option that you want, and click OK.

Your report appears with groups for the field that you selected in the Insert Group dialog box and sorted in the order that you selected in your parameter prompt. To select a different sort order, click the Refresh button and choose "Prompt for new parameter values." The groups in your report are resorted to comply with the new order option that you selected.