Skip to main content
Inspiring
April 24, 2007
Question

Subtotals in CF Reports

  • April 24, 2007
  • 3 replies
  • 830 views
I am trying to produce a report in CF. I know that I can use qry.recordcount to give me the total records, based on my query selection criteria.

But how do I produce and display a subtotal ? For example, if all output is sorted by dates and at the end of each date break, I want to show a subtotal/count of the records for those dates, something like "total number of records for #date_x#", then continue with the display and produce another subtotal/count at the next date break, etc. My output would be in a table.

how can that be done ?

Thanks in advance
    This topic has been closed for replies.

    3 replies

    April 26, 2007
    In that case, <CFSET subTotal = subTotal + 1> is correct.
    April 25, 2007
    You are adding dates to your subtotal. What do you really want to do?
    trojnfnAuthor
    Inspiring
    April 25, 2007
    I want to subtotal (count) the number of records for each date. For example, the output above, the count for 4/7 is 1, etc.
    April 24, 2007
    The code below should give you an idea of how to proceed. Code is untested.
    trojnfnAuthor
    Inspiring
    April 24, 2007
    I can't quite get it to work. I took your code and modified a abit and was able to get the break at dates, but the subtotal did not come out right. Had to put everything back.

    Below is my original code of how I want my report to look, just need the subtotal after each date change. Where would I insert your commands ?

    <center>
    <table border="1" bordercolor="black" width="100%" height="100%" cellspacing="0" cellpadding="2">
    <tr>
    <th>Ticket Number</th>
    <th>Date Created</th>
    <th>Date Shipped</th>
    <th>PO Number</th>
    <th>Bill of Lading</th>
    <th>Packing Sheet Number</th>
    <th>Carrier</th>
    <th>Ship To</th>
    </tr>
    <cfoutput query="qryGet_Shipping_Data">
    <tr bgcolor="###iif(qryGet_Shipping_Data.currentrow MOD 2, DE('C0C0C0'),DE('FFFFFF'))#">
    <td>#qryGet_Shipping_Data.tracenumber#</td>
    <td>#dateformat(qryGet_Shipping_Data.createDate, "mm/dd/yyyy")#</td>
    <td>#dateformat(qryGet_Shipping_Data.dateshipped, "mm/dd/yyyy")#</td>
    <td>#qryGet_Shipping_Data.po_number#</td>
    <td>#qryGet_Shipping_Data.bill_of_lading#</td>
    <td>#qryGet_Shipping_Data.packing_sheet_no#</td>
    <td>#qryGet_Shipping_Data.carrier_name#</td>
    <td>#qryGet_Shipping_Data.ship_to_company#</td>
    </tr>
    </cfoutput>
    </table>
    </center>
    April 25, 2007
    Place the following code mmediately after the </CFQUERY>.