Link to home
Start Free TrialLog in
Avatar of garyjgs
garyjgsFlag for United States of America

asked on

Crystal Reports Field Cannot Be Summarized Error

When passing a variable from a subreport to the main report, an error is received when trying to Count or Sum this variable from the subreport: This field cannot be summarized when using Count({subreport variable}).  The variable in the subreport does a Distinct Count of employees.
The main report is grouped by employees then by location.  A total of the Distinct Count of employees is need by Location.
Avatar of namanpatel
namanpatel
Flag of India image

Count can be used with database field, formula field or array of values. Please make sure you are passing variable of array type.
Avatar of garyjgs

ASKER

This is the variable passed to the Main Report:
//@SubFormula
//Count of teachers teaching core classes
//{#emp nr distinct ct} field
//Shared variable

WhilePrintingRecords;
Shared numberVar TeachersCoreClassCt := 0;
Shared numberVar TeachersCoreClassCt := {#emp nr distinct ct};
TeachersCoreClassCt

When in the Main Report, this variable TeachersCoreClassCt needs to summed.  
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of James0628
James0628

One small, but important, correction to mlmcc's middle formula.  It should read:

TeacherCount := TeacherCount + TeachersCoreClassCt;


 Also, just to clarify, that formula needs to be in a separate section from the subreport, to make sure that it is evaluated after the subreport.  For example, if the subreport is in a Location group footer section, create another Location group footer section below that and put the formula there.  You can suppress the new section.  The formula will still be evaluated.

 James
Thanks James.  Too quick with the paste.

I agree it should be in a later section though if done in the correct order it will work in the same section.  I always do it in a later section to ensure it works since it is too easy to get the order wrong if it is in the same section.

mlmcc
That's the thing.  I don't know of any way to make sure that the formula is evaluated after the subreport if they're in the same section.

 James