Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to count number of grouped rows in the Crystal Report

I need to count and show number of rows of grouped data in the report. I already have number of rows of total data in Report Footer section (I used Count() function and that works fine), but I need to have total rows in the Group Footer section which shows number of rows of grouped data. The visible explanation of the problem is shown under.

Thanks.

----------------------------------------------------
Group 1

        row 1---------------------------  
        row 2---------------------------
        .
        .
        .
        row N---------------------------
--- I need here number of rows!---------------------
----------------------------------------------------
Group 2

        row 1---------------------------  
        row 2---------------------------
        .
        .
        .
        row M---------------------------
--- I need here number of rows!---------------------
----------------------------------------------------
Total Rows: M+N
like image 262
Ferid Š. Sejdović Avatar asked Jul 01 '14 11:07

Ferid Š. Sejdović


2 Answers

Try the solution

  1. Create a formula @reset. Place the formula in groupheader and supress

     Shared Numbervar count;
     count:=0
    
  2. Now create one more formula @ Increment and place in section where there are rows I have assumed it as detail section and supress.

    Shared Numbervar count;
    count:=count+1;
    count;
    
  3. Now create one more formula @Display. Place this formula in Group footer

    Shared Numbervar count;
    Shared Numbervar Count_Final;
    Count_Final:=Count_Final+count;
    count;
  4. Now create one more formula @DisplayFinal and place in Report Footer

    Shared Numbervar Count_Final;
    Count_Final
like image 69
Siva Avatar answered Sep 30 '22 18:09

Siva


This solution may help someone,

Create a Running Total:

  1. Choose a field
  2. Select distinct count as Type of summary
  3. Choose your group name in Reset section
  4. Now drag and drop the running total field in group footer.

Refer the image below enter image description here

like image 31
Palanikumar Avatar answered Sep 30 '22 19:09

Palanikumar