Conditionally Displaying Summary Lines and Text

In addition to using summary lines to control the look and content of your report, you can specify WHEN criteria to control the conditions under which summary lines appear for each vertical (BY) sort field value. WHEN is supported with SUBFOOT, SUBHEAD, SUBTOTAL, SUB-TOTAL, SUMMARIZE, RECOMPUTE, and RECAP.

Example: Conditionally Displaying Summary Lines and Text

In a sales report that covers four regions (Midwest, Northeast, Southeast, and West), you may only want to display a subtotal when total dollar sales are greater than $11,500,000. The following request accomplishes this by including criteria that trigger the display of a subtotal when dollar sales exceed $11,500,000 and subfooting text when dollar sales are less than $11,500,000.

TABLE FILE GGSALES
SUM UNITS DOLLARS
BY REGION
BY CATEGORY
ON REGION SUBTOTAL
WHEN DOLLARS GT 11500000
SUBFOOT
"The total for the <REGION region is less than 11500000."
WHEN DOLLARS LT 11500000
END

The output is:

Region       Category     Unit Sales  Dollar Sales       
------       --------     ----------  ------------       
Midwest      Coffee           332777       4178513       
             Food             341414       4338271       
             Gifts            230854       2883881       

The total for the Midwest region is less than 11500000.  
Northeast    Coffee           335778       4164017       
             Food             353368       4379994       
             Gifts            227529       2848289       

The total for the Northeast region is less than 11500000.
Southeast    Coffee           350948       4415408       
             Food             349829       4308731       
             Gifts            234455       2986240       

*TOTAL Southeast              935232      11710379       

West         Coffee           356763       4473517       
             Food             340234       4202337
             Gifts            235042       2977092

*TOTAL West                   932039      11652946


TOTAL                        3688991      46156290