How to count number of grouped rows in the Crystal Report
Solution 1
Try the solution
Create a formula
@reset
. Place the formula ingroupheader
andsupress
Shared Numbervar count; count:=0
Now create one more formula
@ Increment
and place in section where there arerows
I have assumed it as detail section andsupress
.Shared Numbervar count; count:=count+1; count;
Now create one more formula
@Display
. Place this formula inGroup footer
Shared Numbervar count; Shared Numbervar Count_Final; Count_Final:=Count_Final+count; count;
Now create one more formula
@DisplayFinal
and place inReport Footer
Shared Numbervar Count_Final; Count_Final
Solution 2
This solution may help someone,
Create a Running Total:
- Choose a field
- Select distinct count as Type of summary
- Choose your group name in Reset section
- Now drag and drop the running total field in group footer.
Refer the image below
Solution 3
Another way to try by using Summary
Right Click > Insert > Summary
Choose Field (I choose string value)
Choose "Count" to Calculate This Summary Combo box
Choose Summary Location in Where would you like to show this total
Then OK
Solution 4
This solved my problem Create new formula field
{IM_INV.QTY_ON_HND}-{IM_INV.QTY_ON_HND}+1
{Existing field} minus {exiting field} plus 1
This gave me a "1" next to each detail line in a field I called {NumberForCount}
Because it was made this way it showed up in running total field options
Then made a running total field like normal in the footer
Ferid Š. Sejdović
MSc. Mechatronics, Robotics, and Automation. Electrical Engineer. Developer. High school teacher. https://www.linkedin.com/in/fsejdovic/
Updated on March 17, 2022Comments
-
Ferid Š. Sejdović about 2 years
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
-
Sun about 7 yearsWhat if I have more than one group I want to count but want to show two running totals in the same row (e.g. Group Footer 1)? I have two running total rows within Group Footer 2.
-
Ferid Š. Sejdović almost 6 yearsI was working with Crystal Reports a long time ago. I solved my problem. Thanks for your reply.