Search code examples
sqlcrystal-reports

Crystal Report formula to reset a count?


I want to get the total qty of items sold by year by each part number. So far I have the following formula:

if {INVOICE_DATE} >= DateTime(2012, 01, 01) and 
   {INVOICE_DATE} <= DateTime(2012, 12, 31) 
THEN Sum ({INVOICE_QTY) 

Now, that formula just sums all the parts sold in that year. What I need is for it to reset the sum as it count through each invoice and by each part. How can I do this?


Solution

  • Your formula is not doing what you think it is. For each row in your report (I'll assume that this is by an Invoice_ID or something along those lines) this will simply display the grand total sum of {INVOICE.QTY} for all invoices in the report and will not change from row to row.

    To get something that is like your image, you need to create a Cross-Tab object and configure it such that its rows are based on the Product_ID, the columns are based on Invoice_Date and set to be printed "for each year", and set the "Summarized Fields" to be the sum of {INVOICE.QTY}.