Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: not allowing summaries Post Reply Post New Topic
Author Message
Megan10e
Newbie
Newbie


Joined: 19 Aug 2010
Online Status: Offline
Posts: 24
Quote Megan10e Replybullet Topic: not allowing summaries
    Posted: 08 Dec 2010 at 6:43am

I'm trying to do summaries of amounts generated by formulas, and I realize that crystal won't let me do this because they are totals that have already been through several formulas. But is there a way to tell crystal to do all the other calculations first and then just sum up the results?

I'm looking at a report that gives me totals for individual orders (group footer 1), and I just want to add those up by customer name (group footer 2). It won't let me use summaries or running totals to get these amounts.
 
Is there an easy (or difficult!) way to do this?
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 08 Dec 2010 at 9:24am
I put together a sample orders report grouped by name, so if John has placed 3 different orders, all 3 entries would be grouped together.

I then wrote a "double" formula that doubles all of the amounts owed and displayed it in a column to the right.

I also wrote a "tax" formula that will take the "double" amounts and apply a 15% tax to it, and displayed it in a column to the right of it.

I then used a summary and summed on the "tax" formula, based on the name Group so that I have the total amount that each person owes me after it has been doubled and taxed.

Does this sequence of steps seem similar your report? (having multiple formulas applied to the source values)



Edited by Keikoku - 08 Dec 2010 at 9:32am
IP IP Logged
Megan10e
Newbie
Newbie


Joined: 19 Aug 2010
Online Status: Offline
Posts: 24
Quote Megan10e Replybullet Posted: 08 Dec 2010 at 9:44am
I'm not sure- my formulas that I want to sum by already have sums in them.
 
So, I had to calculate an order total for each order, with a discount taken out. But I also had to use a calculation to get the order total, since I have to exclude certain items from the order. So I have an "order total" formula which is (qty * unitprice). Then I have an "order total with discount" formula which is (sum(@ordertotal, order#) - @discount), which gets me the order total minus the discount for each order. I had to use a formula to get the discount amount too.
Then, to get the summary by customer, I want to do a formula like this:
sum(@ordertotalw/discount, customer) - sum(@discount, customer). But it says those formula fields cannot be summed up.
I think the problem goes back to having to use (qty * unit price) as an initial formula for the order total, because then there are just too many formulas involved!
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 09 Dec 2010 at 3:16am
Ya..it's most likely the fact that you're trying to summarize a summary.

When I had something like sum ( sum ( ...)) it said the inside couldn't be summed up.

I would find a different way to calculate the customer summary. Is it absolutely necessary to take the order sum?

Edited by Keikoku - 09 Dec 2010 at 3:47am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 09 Dec 2010 at 3:40am
Crystal doesn't allow aggregates on formulas because it would require another pass through the data, which Crystal does not do.  The value is 'known' until the report is run, by which time it is too late, Crystal calculates the aggregates during the second pass through the data (I think). 
 
I usually think of aggregates using the values that come straight from the database. So if the value is not exactly from the database, Crystal won't sum it, might sum it incorrectly (if you conditionally suppress the display of a field, but use SUM on the field, all the values are display irregardless of the conditional suppression).
 
So the answer is:
 
variables...I like shared, though global will work as well.
 
They come in groups of 3, each is formula
1) reset, usually in a group header:
shared numbervar aTotal :=0;
"" //suppresses the 0 from being display
 
2) increment, usually in details, but in this case if gf2
shared numberbvar aTotal;
aTotal := aTotal + {another formula};
OR
aTotal := aTotal + {table.field};
""  // same reason
 
3) display, usually in a group footer
shared numbervar aTotal
 
HTH


Edited by lockwelle - 09 Dec 2010 at 3:44am
IP IP Logged
Bmowrey
Newbie
Newbie


Joined: 10 Dec 2010
Location: United States
Online Status: Offline
Posts: 4
Quote Bmowrey Replybullet Posted: 10 Dec 2010 at 5:17am

I created a formula field “IncRespTime”

if {@RespTime}=Minimum ({@RespTime}, {Trips.IncidentID})then Minimum ({@RespTime}, {Trips.IncidentID})else 0

I placed this field in the report, I set to suppress if 0 which shows the correct response time for the incident.

Date                        Inc#              Run#           TOC                   TOS                     RespTime              Unit         IncRespTime

2010-04-13     26,009   14,082    05:27:41    05:37:47      10.10             45

2010-04-13     26,009    14,083   05:27:56    05:35:44       7.80              Fx1          7.80

 

But when I try to get the average of that field I get an error that I cannot summarize that field. 

I hope this makes since

IP IP Logged
hmmmmmm
Newbie
Newbie


Joined: 11 Dec 2010
Online Status: Offline
Posts: 7
Quote hmmmmmm Replybullet Posted: 11 Dec 2010 at 11:20pm
Originally posted by Megan10e

It won't let me use summaries or running totals to get these amounts.

 



How You Try To Summarize The Total Amounts ????
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 13 Dec 2010 at 5:10am
same solution.  You will need to calculate the average yourself using running totals(maybe, they are not my forte) or variables (my forte, see above)
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.