How to count number of grouped rows in the Crystal Report - crystal-reports

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

Try the solution
Create a formula #reset. Place the formula in groupheader and supress
Shared Numbervar count;
count:=0
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;
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;
Now create one more formula #DisplayFinal and place in Report Footer
Shared Numbervar Count_Final;
Count_Final

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

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

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

Related

crystal reports sum only last item in detail

I wish to display in the group footer the sum of the sold qty column (which is easily done) and then only the last value of the on hand qty column.
I think a variable can do this, but not sure how to do it as I'm new to Crystal and its variables.
Here is an example
Sold qty On Hand Qty
details 1 5
2 3
============================================
GF Total 3 3
============================================
details 6 10
3 7
============================================
GF Total 9 7
Put the field {yourTable.OnHandQty} in the group-footer.
This will show the last detail value and will work as long as there's no suppression on details.
Note: The "last record" is determined by the sort within the group. This means that if the sorting is changed, the wrong value will be displayed.
Yes !! You can do this using variables.
Step 1: Create a Formula Field Named as OnHand
OnHand
shared numbervar OnHand;
Onhand := (Your Table Field) + Onhand +;
Place this one in Details section and suppress it (Right Click
Formula --> Format Field --> Common --> Supress)
Step 2 : Create one more formula to display the result
PrintOnHand
shared numbervar OnHand;
OnHand;
Place this formula in Group Footer
Step 3 : Create one more formula Clear
Clear
shared numbervar OnHand;
OnHand :=0;
Place this formula in group Header and suppress it. (This is to clear the Onhand
Value for every records or group).

alternate row color and Can Grow field in Crystal Reports

In my report each row contains many fields and one of them is set to Can Grow.
I have alternate row color for easier row separation with a fomula like
if recordnumber mod 2 = 0 then crTeal else crNoColor.
However because the Can Grow field takes up multiple lines my alternate colors mess up.
Any idea how I can overcome this problem?
Not sure if the Can Grow field is the problem after all.
Sometimes I have for 2 or 3 rows the same color.
I have 3 groups like Products, status of Product (sold out etc..), Customer. I had to make a group for Customers because I wanted the latest date of a field and I read that this is a way to do it.
Problem is not with can grow...problem is with the formula.
When you have huge data and many groups then row number will generate the number which is not necessary the serial number and when you do modulus on that result will be one that you got.
Try this solution
Create a formula #initialise place in a section that is above the section where you show data
Shared numbervar counter;
counter:=0;
Create formula #count place in section where you show data
Shared numbervar counter;
counter:=counter+1;
Create a formula #reset place in a section after the section where you display the data
Shared numbervar counter;
counter:=0;
Now write your formula as
Shared numbervar counter;
if counter mod 2 = 0
then crTeal
else crNoColor

Crystal Report How to sum of field OldAmount from second table where date is less than the provide Param datefield

i have 2 table named as TB_NewBills and TB_OldPayment , TB_NewBills have colums ClientName ClientID DateofBuying NewBillAmont and ![TB_OldPayment][1] have colums cusomterName CustomerID DateofAmount OldAmount
i used 2 paramters in my report Param-clientID and Paam-date upon which i am fetching fields data and fields are displyed on reports are ClientName ClientID DateOfBuying NewBillAmount and in footer i have sum of newBillAmount
Second Part :
Problem is now i want to get the sum of column TB_OldPayment . OldAmount where TB_Old Payment . DateofAmount < param-date i cant make up with my problem i have done all up to first part please help
image link to see digram http://i58.tinypic.com/99qn7m.jpg
Thx
if you have subreports you will have to create a shared numbervar variable for TB_OldPayment where you are going to storage a running total of your OldAmount where DateofAmount < param-date. Then put that formula on your main report on report footer
if you don't have subreport just create a running total of your OldAmount where DateofAmount < param-date and put on report footer

How do I create a Grand Total Summary based on a Group Summarized Formula In Crystal 10?

I have the following formula: #Sales_Cost
(Sum({Estimate_Retail_Inventory_Change___Detail.Sales_Ret_Final_Amount}, {Estimate_Retail_Inventory_Change___Detail.Inv ID}) -
(Sum ({Estimate_Retail_Inventory_Change___Detail.Sales_Ret_Final_Amount}, {Estimate_Retail_Inventory_Change___Detail.Inv ID}) *
{#GM%_For_Cost_Sales}))
This produces the following results and I have placed in my GH2 section:
592.77
1038.26
2628.38
3598.62
356.58
I want to total those values for my Report Footer, but I get the error message, "This field cannot be summarized".
How do I do this?
You need to create a manual running total. To do this you will create 3 new formula fields.
The first one goes in the report header to initialize the running total variable.
WhilePrintingRecords;
NumberVar manualTotal :=0;
The second one goes in the group header with your summary formula.
WhilePrintingRecords;
NumberVar manualTotal := manualTotal + {#Sales_Cost};
The third one goes in your report footer to display the calculated value.
WhilePrintingRecords;
NumberVar manualTotal;
manualTotal;;
Assuming {#GM%_For_Cost_Sales} will not vary within each Inv Id value (though it could vary across different values) and that the group for GH2 is on Inv Id, the simplest way to do this would be to change your formula item to:
{Estimate_Retail_Inventory_Change___Detail.Sales_Ret_Final_Amount} *
(1 - {#GM%_For_Cost_Sales})
- and place summed #Sales_Cost fields into both your GH2 group header and report footer sections.

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?
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})
Right-click on any field in Details section, Insert Summary, select Count(), drag resulting field into page (report, group) header.
I just summarized the field with Count and put it to Group Header That's It.