SAP Knowledge Base Article - Public

1211557 - Error: 'Summary cannot be performed, a group must be created before', when creating a formula in Crystal Reports

Symptom

  • Error: "Summary cannot be performed, a group must be created before"
  • In Crystal Reports, when creating a formula to summarize values it displays an error.

Environment

  • SAP Crystal Reports 2008
  • SAP Crystal Reports 2011
  • SAP Crystal Reports 2013
  • SAP Crystal Reports 2016

Reproducing the Issue

  1. In Crystal Reports, create a report off any data source.
               
  2. Creating a formula using one of these summary functions:
    • Average (x)
    • Count (x)
    • DistinctCount (x)
    • Maximum (x)
    • Minimum (x)
    • Sum (x)

      For example, the formula will be like:  
       
             Sum({Field1},{Filed2})

      Where {field2} is a Date field, results in the error message:
         
  3. When attempting to save the formula it displays the error: "Summary cannot be performed, a group must be created before" 

Cause

  • The second database field in a summary function represent a group, and the report is not grouped by the database field specified.

Resolution

  • To use a summary function in the formula, you need to already have the report grouped on the datatabase field {field2}, which in this case is a Date field.
                  
  • Also, when grouping a report by a Date field, you need to indicate the frequency of the grouping:
    • For each day,
    • For each week
    • For each two weeks
    • For each half month
    • For each month
    • And so on...
         
  • Similarly, when creating a formula that summarizes a field and subtotals it by a Date-based group, you need to specify in the formula how frequently it is grouped. The correct syntax is:
       
           SummaryFunction({field1}, {field2}, "frequency")
       
    For example, to get the count of Order IDs for each Order Date group, which groups for each month:
         
           Count({Orders.Order ID}, {Orders.Order Date}, "monthly")

Keywords

DATE SUMMARY COUNT SUM GROUPING BY DATE SUMMARY FUNCTIONS FORMULA EDITOR Seagate Crystal Reports Summary functions Date-based groups , c2006060 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , Problem

Product

Crystal Reports 2008 V0 ; Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports 2016