The reason you can't create a summary field in Crystal reports

Published:
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples).

Crystal Reports uses a two-pass reporting process to provide greater Reporting capabilities. It is also largely responsible for determining what is and is not possible to do in Crystal Reports.

Understanding this two-pass process will explain many common questions, such as:
1. Why does a formula produce the error?
2. Why am I able to insert summaries on some formulas, but not on others?

3. Why are my grand total and/or summaries incorrect after performing a group selection or Top N/Bottom N sort?

Answers to these questions are:
1. Why does a formula produce the error?

"The function cannot be used because it must be evaluated later"?

Answer: This error usually happens when trying to insert a second pass function into a record selection. Since Crystal Reports evaluates record selection formulas during the first pass of the data, they cannot contain second pass functions.

In general, second pass functions are functions that require data from more than one record. Examples of second pass functions (also known as WhilePrintingRecords or print-time functions) are Next, Previous, TotalPageCount, NextIsNull, PreviousIsNull.

2. Why am I able to insert summaries on some formulas, but not on others?
Answer: Crystal usually evaluates formulas during the first pass of the data. These formulas are known as recurring formulas. However, if the formula contains a second-pass function (these functions are explained in the answer for (1), above), this forces Crystal Reports to evaluate the formula during the second pass instead.

Crystal Reports creates summaries shortly after evaluating any recurring formulas during the first pass. Since SCR has yet to evaluate the second pass formulas, it cannot create a summary for them.

To summarize second-pass formulas, create running totals using variables and the WhilePrintingRecords function.

3. Why are my grand total and/or summaries incorrect after performing a group selection or Top N/Bottom N sort?

Answer: While record selection is evaluated during the first pass, group selection is evaluated in the second pass. Because Crystal Reports creates summaries in the first pass (therefore prior to evaluating group selection), the summaries don't reflect the groups that have been suppressed from the report.

To correctly summarize and/or grand total a report that has a group selection formula, creating running totals, either using variables and the WhilePrintingRecords function, or with the Running Total Expert (available only with version 7 and higher).

Hope you find this article helpful.
Eileen
www.crystalreportsbusiness.com
3
8,628 Views

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.