Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The reason you can't create a summary field

Formula Help

The reason you can't create a summary field

by  emcevoy  Posted    (Edited  )
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).

Cyrstal Reports uses a two-pass reporting process to provide greater reporting capabilities. It is also largely responsble 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?

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

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 8).

There is this document and many other useful and informative documents regarding crystal reports and evaluation time, functions, formula, crosstabs and much more.

You can find this document at the following address.
http://www.sdn.sap.com/irj/boc/go/portal/prtroot/docs/library/uuid/e055cd62-f91f-2b10-e99d-c5f930a75ca8?QuickLink=index&overridelayout=true

Hope you find this helpful in your crystal reports development.
Eileen
www.crystalreportsbusiness.com
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top