Symptom
- Error when saving a formula.
- When checking a formula, Crystal Reports returns the error:
"The function cannot be used because it must be evaluated later"
What causes this error, and what does it mean?
Environment
- SAP Crystal Reports 2011
- SAP Crystal Reports 2013
- SAP Crystal Reports 2016
Reproducing the Issue
- In Crystal Reports, create a report off any data source.
- In a Record Selection Formula, enter something like:
Sum({Database Field A} > {Database Field B} - When trying to save the formula, it fails with the error: "The function cannot be used because it must be evaluated later"
Cause
- This error occurs when trying to insert a second pass function into a Record Selection Formula, and a Record Selection Formulas is evaluated during the the first pass to translate the formula into a SQL Query, and therefore, it cannot contain second pass functions that aggreate values, like: Sum, Maximum, Minimum,... as well as functions like: Next, Previous, TotalPageCount, WhilePrintingRecords,...
- This error can also happen if you used the function 'WhileReadingRecords' in a regular formula to ensure Crystal Reports evaluates it during the first pass of the data, but then added a second pass function to this formula.
- For more information on how a report is process in Crystal Reports, see the SAP Knowledge Base Article:
2594391 - How is a report processed in Crystal Reports?
Resolution
- Remove the second pass functions from the formula.
Keywords
CR , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , Problem
Product
SAP Crystal Reports 2011 ; SAP Crystal Reports 2013 ; SAP Crystal Reports 2016