Crystal Report Grouping - crystal-reports

I'm having some problems with grouping and running totals in crystal reports, I've found loads of info whilst googling but I'm looking a bit more info.
Currently I have 3 tables, jobs, times and costs, I have a running total to calculate the value of the time.hours and another for the costs.amount.
The issue I'm having is that the costs are being multiplied by the amount of time.hours records that exist.
so if a job has 3 time.hours records and there is only one record of costs.amount that
cost is being multiplied by that about of records
So what i end up with is this
Job Hours Costs
123 5 0
123 4 100
123 3 0
=========================
12 100
which is exactly right, now if i add another running total without resetting then my total ends up as
========================
12 300
I think this is happening because of the way i have them grouped but im not sure how to make them group to only job.ID

This was solved using ( ) to break the formula down
({timesheet.Time_Date} <={?timDateUJC} and {jobsheet1.Job_JobCompleted} = 0)
or
({materialcost.Inv_Date} <= {?supDateUJC} and {jobsheet1.Job_JobCompleted} = 0)

Related

How would I configure analyze threshold for a table where the data is categorically different every couple months?

We host data for an auditing service. Every few months, a new audit comes out with similar questions to previous audits of the same category. Since questions can change verbiage and number, we store each question in each audit separately (we do link them through a "related_questions" table).
audits
id
name
passing_score
1
audit_1
100
2
audit_2
150
questions
id
audit_id
text
1
1
q1
2
1
q2
3
2
q1
4
2
q2
We then have a surveys and responses table. Surveys are the overall response to an audit, while responses store the individual responses to each question.
surveys
id
audit_id
overall_score
pass
1
1
120
true
2
1
95
false
3
2
200
true
4
2
100
false
responses
id
survey_id
question_id
score
1
1
1
60
2
1
2
60
3
2
1
60
4
2
2
35
5
3
3
100
6
3
4
100
7
4
3
50
8
4
4
50
The analyze threshold is base threshold + scale factor * number of tuples. The problem with this is that once an audit has finished (after a few months), we'll never receive new surveys or responses for that category of data. The new data that comes in is conceptually all that needs to be analyzed. All data is queried, but the new data has the most traffic.
If 10% is the ideal scale factor for today and analyze autoruns once every week, a couple years from now analyze may autorun once every 4 months due to the number of tuples. This is problematic when the past 3 months of data is for questions that the analyzer has never seen and so there are no helpful stats for the query planner on this data.
We could set the scale factor extremely low for this table, but that seems like a cheap solution that could cause issues in the future.
If you have a constant data modifications rate, setting autovacuum_analyze_scale_factor to 0 for that table and only using autovacuum_analyze_threshold is a good idea.

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.

Ignore Duplicates in Count

I have a report in Crystal that won't total correctly.
I have groups set up as show below:
Date
Hour
Item
The actual data is:
8/20/2013
9.00
5411400
5411468
5411497
10.00
5411600
5411671
14.00
5411468
5443140
15.00
5441468
16.00
5443714
5443764
5443813
What I need is a count of each of the 5xxxxxxx numbers for each group, but only counting duplicates once for the whole set. How is should appear is:
Hour - Total
09 ------ 3
10 ------ 2
14 ------ 1
15 ------ 0
16 ------ 3
Is this possible in Crystal? I've tried creating a formula, a running total (with and without a formula), and various summations (using distinct and non-distinct counts), but none of them produced the right result. It seems so far that I can only make Crystal calculate distinct counts per each subgroup containing the 54xxxxx numbers and not via the hour.
I am confused with below line as you said you want the count of 544xxx but here in 9th hour there is no 544**
What I need is a count of each of the 544xxxxx numbers for each group, but only counting duplicates once for the whole set. How is should appear is:
Tell what exactly you need. Will try to help
I found the solution: In this particular report, there was a sub SQL query that was causing the duplicates. I changed the sub-query to not generate an "hour" for each entry but instead for each order.

Crystal Reports - group total at begining of group

I have this report:
Question Group
----Question - [TOTAL]
--------Answer 1 (10)
--------Answer 2 (0)
--------Answer 3 (8)
--------Answer 4 (2)
----Total: 20
Total: 20 is calculated with running total field, and it can only be calculated after each question finishes.
What I want is to place this value at the beginning ([TOTAL]), so it can be used to calculate percentages (--------Answer 1 (50%)).
I tried with formulas, with no success.
I managed to change the SQL that feeds the report and then used a formula to do what I want
count({newfield},{group})

How to add a conditional grand total in Crystal Reports?

I have a group running total that needs to be sum up at the report footer. Since thats not possible with CR I had to end up having another running total that refreshes "Never". But now I need to calculate some percentages at the group level based on this Grand total. Unfortunately I cannot access the value for grand total (because its another running total).
Confused?? Ok reports should look like below..
Column 1 | Colunm 2
======== =========
| Group 200 (Running Total Refresh at Group level) | 20% (200%1000) |
| Group 500 (Running Total Refresh at Group level) | 50% (500%1000) |
| Group 300 (Running Total Refresh at Group level) | 30% (300%1000) |
Footer 1000 (Running Total Never Refreshed)
But column 2 doesn't give me the correct value. it gives me 100% always means 200%200 or 500%500 etc.
Any idea how to fix this??
Thanx Lee, using a running total formula worked, I added following formula to the report footer,
numbervar Samples;
if {product.sku}="card-sample" then
Samples := Samples + {#num_qty};
Samples;
Then I use this formula to calculate column 2
Try this
Add a formula field for group percentage and then paste below code in it.
Group total / sum(column)
place this formula at your group level.
I should think your report total wants to simply be a summary field not a running total. Then your column 2 value can be calculated using running total / sum(field);
Here is an example:
I have two columns age and salary.
When age > 18 i want to add the salary.
Initially I used a running total with a condition {age} > 18
That didn't work well so i deleted the running total, and created a formula: if {age} > 18 then {salary} else 0
I then created a summary on that formula field.
Make sense?