Search code examples
crystal-reports

In Crystal Reports, How do I count all the rows in the Details section and place that count in the header?


I've tried adding a new formula and used this code:

whileprintingrecords;
numbervar x;
x := x + 1;

Problem is, if I place the formula that displays the count on the header section, it only shows the first value since it hasn't yet incremented.

I need a total count of the rows in every page and just show it in the header. how do I do this?

Wait I just realized it is placed in a group not in the details section. Let me revise my question. How do I get the value of the display formula in the last page of the report? Makes sense?


Solution

  • The simplest way to get a total count of all the rows within the report and place it in the page header is to create a new formula, with the value:

    Count ({Table.Value})
    

    and place it in your page header (where Table.Value is a field in your dataset).

    EDIT: To get a total count of all the groups, change the formula to:

    DistinctCount ({Table.GroupField})