Sum of an average Crystal Reports - 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':

Related

Data studio calculated fields

I have the following dataset:
Week #
Company Name
Product
# of transactions
Week1
Company A
Product 1
100
Week1
Company B
Product 1
30
Week1
Company A
Product 2
100
Week2
Company B
Product 2
50
My goal is:
for each COMPANY (there could be multiple rows per company) calculate Usage score with the following formula total # of transactions per company/100. For example, from the table above Company A has 200 transactions and Usage score=2 - I've done it successfully
categorize each company per the following formula: when usage score>1 then "promoter" else "critic" - I've done it successfully
Count promoters and critics - that's where I fail. Data studio in this case calculates Usage score and NPS per row, not per company. Therefore, I have promoters per product, not per company.
please help, I'd appreciate
You can solve this by Re-aggregating the Datasource with itself where the Second Join is the Datasource itself with the Key Company Name and the Metric Usage score make sure to set its Aggregation to Average.
Now you have a new Datasource with each Company and Row having its Usage Score in one column.
Unfortunately I don't understand the NPM part.
Hope this help though

Perform calculation on a different number of rows for each ID

Hopefully someone smart here can help me with a description how to solve this issue. I am relative new to SPSS and want to select cases with a certain requirement.
I have a group of Identeties who has made a mathtest multiple of times. We have 1000 ID where each person (ID) has done the test 10 times. Now i wanna select how many of these persons have scored atleast 40/50 once in this test. I have managed to do so.
Here is the problem. I now wanna calculate the average score of all the tests every individual has done after the first time they scored atleast 40 points.
Example: ID nr 8 has a score of; 34,35,27,37,32,45,41,32,34,47
These are all in 10 different rows. So ID nr 1 appears in 10 different rows. ID 2 in 10 other rows and so on.
Like this:
ID 1 Score 34
ID 1 Score 35
ID 1 Score 27
As you can see the person has scored atleast 40p at the 6th time. And i wanna take the average henceforth from this point. So in this case (45+41+32+34+47)/6.
I also wanna know how if i consider a person "smart" or not. A smart person is someone with atleast 2 mathscores with 40p+ (dosent have to be after each other, 2 seperate occations is ok)
How do i do that?
In the following code I assume you have a variable that identifies the order of the tests for each ID:
sort cases by ID TestNumber.
compute ScoreOver40 = score >= 40. /* this identifies all scores g/e 40.
compute seq=ScoreOver40.
* if seq was 1, all following seq values for same ID will also become 1.
if ID = lag(ID) and lag(seq)=1 seq=1.
if seq=1 scoresAfterFirst40 = score.
*now to aggregate by ID.
dataset declare agg.
aggregate /out=agg /break=ID /meanAfterFirst40=mean(scoresAfterFirst40)
/NumScores40P = sum(ScoreOver40).
In the new dataset called agg you should find for every ID the mean of scores after the first score of 40 or more, and the count of scores of 40 or more in all the 10 tests.
EDIT:
Now you can use the aggregated data for further analysis. For example, you can determine which IDs had two or more high (40+) scores:
dataset activate agg.
compute GoodAtMaths = (NumScores40P >= 2).
exe.

How do i make a calculated field in access which is the sum of data from a query?

I have these 3 tables:
job(job_num, job_cost)
item(item_id, item_name)
job_line(job_num, item_id, cost)
Now in access i have a form that deals with the job table and a subform within that form that deals with job_line. job_line is to allow multiple items to be on a single job record(job_line is the relational table).
Now I am trying to get job_cost in the main form to be a calculated field where by is sums the costs in the result set for job_line.
EG:
table:job
job_num : 3
job_cost : 0
table:job_line
job_num : 3
item_id : 1
cost : 100
job_num :3
item_id : 2
cost : 50
Therefore i wish that job_cost would dynamically update to 150 to reflect the sum of the two entries within job_line.
I am using Microsoft Access 2013.
Since I do not see your actual query I will give you an example of how to calculate the total cost in the SQL view. The key is the second select statement which calculates the field and displays it as a column.
SELECT job_line.job_num, job_line.item_id, (Select Sum( job_line.cost) from job_line) AS TotalCost
FROM job_line
Group by job_line.job_num, job_line.item_num;

Group Sum not adding a row in 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.

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.