title: "Rolling up" groups in Jaspersoft iReport
body: <p>I have a profit and loss report that currently has three levels of grouping:
  1. Pharmacy
  2. Customer
  3. Packaging Type</p>
  
  <p>I've set up the report to prompt the user to provide values for pharmacy, customer, and packaging type. The detail band displays measures like revenue and margin. Selecting the default for pharmacy, customer, or packaging type returns all values in the group.</p>
  
  <p>I'm wondering - is there any way, if the user selects "use default" for a parameter, to tell iReport to roll up the grouping? Right now, if I select a pharmacy and a customer but use the default for packaging type, I still get a detail band for each of several packaging types. How can I tell iReport to sum on ALL packaging types? Or, if no customer is specified, sum on ALL customers for a given pharmacy? Or could I do it in the query? I have an Oracle database and am using iReport Professional 4.5.1.</p>
  
  <p>Thanks,
  Lisa</p>
  
  <p>EDITED TO ADD CODE:</p>
  
  <pre><code> SELECT
        FAC.FILL_MONTH AS FILL_MO,
        FAC.PHAR_CODE AS PHAR_CODE,
        FAC.FAC_ID AS FAC_ID,
        FAC.PACKTYPE_CODE AS PACKTYPE,
        SUM(FAC.TOT_RXCOUNT_NUM) AS RX_COUNT,
        SUM(FAC.TOT_REVENUE_AMT) AS REVENUE,
        SUM(FAC.TOT_COGS_AMT) AS COGS,
        SUM(FAC.TOT_MARGIN_AMT) AS MARGIN
   FROM
        MySchema.Table FAC
   WHERE
        FAC.FILL_MONTH BETWEEN $P{startdate} AND $P{enddate}
        AND $X{IN, FAC.PHAR_CODE, pharmacy}
        AND $X{IN, FAC.FAC_ID, facility}
        AND $X{IN, FAC.PACKTYPE_CODE, packtype}
   GROUP BY
        FAC.PHAR_CODE,
        FAC.FAC_ID,
        FAC.PACKTYPE_CODE,
        FAC.FILL_MONTH
   ORDER BY
        PHAR_CODE ASC,
        FAC_ID ASC,
        PACKTYPE ASC,
        FILL_MO ASC
  </code></pre>