Group Sum not adding a row in Crystal Reports - crystal-reports

I want to do a Group Sum total of OrderQTY per Work Order(WO). At times, I can have multiple rows per Work order because there can be several people on that job sequence per WO. However, for the total I am looking to sum only (Row 1)OrderQTY per Work Order
Example
Group: PARTID - Cog123
WorkID OrderQTY Seq
Row 1 WO1 20 1
Row 2 WO1 20 2
Row 1 WO2 20 1
Row 1 WO3 20 1
I used "Running Total Fields Function"
Summary
"Field to summarize" = OrderQTY
Evaluate
"Use a Formula" = previous(WorkID)<>WorkID
Reset
"On change of group" PartID
However the total I get is 40. I need the answer to be 60. It's misses a row. How do I correct this?
Thank you in advance.

You need to write the running total to evaluate on change of workID then you will get correct answer.

Related

Sum of an average Crystal Reports

For each "Job Number" group there are multiple "Quantity" records. I only require one "Quantity" record per "Job Number", so I have tried to achieve this by using an Average of the "Quantity". This works in isolation at Group Level, however I need to then show an average of "Quantity" at a higher group level
For example, Job Number 100000 has 4 records in the detail level with a Quantity of 5000 for each record, Job Number 100001 has 2 records in the detail level with a Quantity of 2000 for each record
Using the average function, the group level shows Job Number 100000 with one quantity record of 5000 and Job Number 100001 with one quantity record of 2000
At the higher group level, the average should be 3,500 (7,000 / 2) but it actually displays as 4,000 (24,000 / 6)
The formula should be a Sum of the Average Quantity / Distinct Count of Job Number
For the life of me I can't get this to work
Any help appreciated
Thank you
Create a Running Total and set the evaluate condition to 'On Change of Group':

How to Subtract Group total of same field in crystal Reports

Say I have Fields Like
SNo-----S/F----Amt
1--------S---------100
2--------S---------100
3--------S---------100
4--------S---------100
---------------------400 -> Group Total
1--------F---------100
2--------F---------100
3--------F---------100
---------------------300 -> Group Total
1--------R---------100
2--------R---------100
---------------------200 -> Group Total
I want to do like (Grouptotal-S) + (Grouptotal-F) - (Grouptotal-R)
More Like 400 + 300 - 200 = 500 as Grand Total.
I searched the internet and came across evaluateAfter but didn't understand how to apply because all the example shows group subtract between 2 different fields and I have a single field here i.e (Amt) in different Groups
Edited :
To understand more, I am adding some images below.
Image 1:
Image 2:
Note: I solved my problem by using RunningTotal but I have to take 2 running totals for 1 field and I have approx 5 fields to do the same.
I just want to know if there an easy way just subtract the group total of the same field??
Please rectify me if I am wrong somewhere in the question.
Thank You
Does the formula not work for this?
Have you tried creating a new formula and you can find your group totals under Report Fields. Write your formula as needed and then you can place that formula in the report/page footer.
Example
(Group 1 SUM + GROUP 2 SUM) - GROUP 3 SUM

Return 0 value if Details duplicated

I need your help in creating crystal report.
I have a formula in details section that computes working time.
How do I make the value return 0 if it is duplicated?
Here's the scenario
Name Time (Hours:Minutes)
John 1:20
........ 3:30
........ 3:30
Total Hours -> ?
My problem is I dont want to use the duplicated values (3:30) like shown above. I want a total hours for 4:50.
you have two options:
check the option in Database tab.. Select Distinct Records so that duplicate records will be eliminated.
If you don't want to use the first option then to calculate use Running Total so that you sum only those that are distinct...
Create running total something like Do sum only after change of time value
You can use the function "previous" to compare the current value with the previous value, but it works only with fields.
But i am not sure if i understood, you may be more precise about your question.
1) make a formula called "hours" or some other name
if not isnull(previous({Result.Time}) and {Result.Time} = previous({Result.Time}
then 0
else {Result.Time} /* you have to assure the same return type */
2) let the "total hours" be a sum of the formula "hours"
Note that it will work only if the rows are ordered by hours.
The result is the same of using a running total fields as purposed by Siva.

JasperReports group by all - display row even if nothing returned

I am trying to get JasperReports to mimic the SQL GROUP BY ALL functionality. I am grouping by MY_BOOL which can either by 0 or 1 and I am displaying the value, and a count on the number of rows in my report. However, I want to display a row for each, even if there are 0 rows for one of the values. So for example, if my query returns ten rows, and MY_BOOL=0 for all ten, I would like to see:
MY_BOOL | COUNT
0 10
1 0
How can I accomplish this in JasperReports?
EDITED:
It sounds like you need 2 variables and no groups.
$V{MY_BOOL_0} counts all rows where $F{MY_BOOL} is 0. $V{MY_BOOL_1} counts all rows where $F{MY_BOOL} is 1. The initial value of each variable is 0, so it doesn't matter if there are zero rows with $F{MY_BOOL} = 0.
Display the 2 variables in the title (or summary or wherever) to provide your 2 "grouped" subtotals.
Note: These 2 variables don't use groups at all, but they would be compatible with groups. For example, you could calculate the MY_BOOL_0 and MY_BOOL_1 values for each month if you group on months.

Crystal Reports - Formula to count groups/How to create an average based on sums

I am working on a report that shows Part Numbers with multiple Purchase Order numbers, Order Quantity and Shipped Quantity. First I grouped Part Numbers.
Part # 21104-2F PO # S7CEO Order Qty: 10 Shipped Qty: 0
PO # S7CEO Order Qty: 10 Shipped Qty: 0
PO # S8LVU Order Qty: 5 Shipped Qty: 0
Sometimes we split jobs within a purchase order. For example: (look above at PO # S7CEO) you order 20 of part # 21004-2F. We separate it into two lines (or jobs) of 10 parts per job. In this report I only want to see that you ordered 20. To achieve this, I created a second group for Purchase Order numbers and inserted a sum so that way I only see that you order 20 parts.
Part # 21104-2F PO # S7CEO Order Qty: 20 Shipped Qty: 0
PO # S8LVU Order Qty: 5 Shipped Qty: 0
My dilemma: I need to show an average based on how many parts you ordered (so average of the 20 parts, not the 10) but CR is giving me an average based on the 10 parts.
How do I create an average based on sums?
I tried using a formula to calculate the sum then divide by line count. There are 3 “lines” but once I grouped and inserted a summary, there are 2 different purchase orders. The line count formula is counting "3" lines. I want it to count how many groups I have so it will come up with "2". Then I will be able to divide "groupcount" (2) by total order qty and that will give me an average. Is there a formula that will help me achieve this?
Thank you in advance!
Yup, Count counts all the records. Use DistinctCount, which counts the values instead:
Sum({OrderQty})/DistinctCount({PO})
That should give you 2 instead of 3 in the denominator.
As long as you're outputting the data into the group footer, you can use a SUM(shipped quantity)/COUNT(PO #) to get the average parts/shipment.
e.g.
Two level grouping on Part # (group #1) and PO # (group #2). You'd output the actual data in the Group Footer #2 field. To do your average, you'd add two summary values in that footer: SUM(shipped quantity) and COUNT(PO #). Then a simple formula field to do SUM/COUNT of those two values, and you've got your average parts per shipment value.