Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: individual totals correct but sum formula not Post Reply Post New Topic
Author Message
tsh1586
Newbie
Newbie


Joined: 25 Aug 2014
Location: United States
Online Status: Offline
Posts: 11
Quote tsh1586 Replybullet Topic: individual totals correct but sum formula not
     Posted: 10 Sep 2014 at 9:23am
I have a report that contains formulas for individual criteria and those items work. When I take one of those formulas and subtract if from my other total it is not pulling the correct amount. Any Ideas?
Here is the formula I am having issues with:
if {fa_master.fa_disposal_date} > DateTime (2013, 06, 30, 00, 00, 00) and
{fa_master.fa_acquire_date} < DateTime (2013, 07, 01, 00, 00, 00) then {fa_master.fa_purchase_cost}
This works by itself and is named disposals but when I put it into the following formula it will not work and I am not sure what it is pulling in wrong:
{fa_master.fa_purchase_cost}+{@PURCHASES}-{@disposals}
The totals are as follows
1,548,194.82+208,721.00-144,752.00 The report is saying this is 36,542.52
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Sep 2014 at 9:46am
are you trying to calculate results across rows like in a group footer or all 3 values correct in one row but your final value is incorrect in that same row (not footer)?
IP IP Logged
tsh1586
Newbie
Newbie


Joined: 25 Aug 2014
Location: United States
Online Status: Offline
Posts: 11
Quote tsh1586 Replybullet Posted: 10 Sep 2014 at 10:47am
I have it as a group footer all 3 amounts are in the group (purchase cost, purchases, and disposals) and they are all showing correct. In the other formula showing where I add purchases and subtract disposals this is also a group footer but not calculating correct.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Sep 2014 at 11:48am
your formula with " {fa_master.fa_purchase_cost}+{@PURCHASES}-{@disposals} " is only going to calculate data form the last row in the group, (unless your purchases and disposals formulas are using shared variables and these are the final amount for the group results).
 
It sounds like you are thinking that each of these formula holds the values the meet the conditions as they run through the rows and adds amounts to them. That would be shared variable formulas or Running Totals with evaluation formula criteria.
 
 


Edited by DBlank - 10 Sep 2014 at 11:54am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Sep 2014 at 11:53am
your "disposals"...
if {fa_master.fa_disposal_date} > DateTime (2013, 06, 30, 00, 00, 00) and
{fa_master.fa_acquire_date} < DateTime (2013, 07, 01, 00, 00, 00) then {fa_master.fa_purchase_cost}
evaluates once per row and returns a value for each row that does not include prior or next rows. If you want to know a toal for the group that all the rows are a part of you need to sum it at the group level
e.g. SUM(@disposals,groupfield)
or use shared variables to increnentally sum the value on each row.


Edited by DBlank - 10 Sep 2014 at 11:54am
IP IP Logged
tsh1586
Newbie
Newbie


Joined: 25 Aug 2014
Location: United States
Online Status: Offline
Posts: 11
Quote tsh1586 Replybullet Posted: 11 Sep 2014 at 2:19am
Each group has subgroups the subgroup and the total group is summed in a footer. I am not understanding what I need to do I tried putting sum in front of my disposal formula sum(@disposals) and it gives me a message and removes all of my data from the report. What am I doing wrong.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 11 Sep 2014 at 4:06am

you cannot really sum a sum.

There is a way to use shared variables to do that.
I would suggest that you rather than trying to fix the formula, you post sample level data and explain what you need it to end up like and why.
My guess is that there is a less complex way to get to your desired end point.
IP IP Logged
tsh1586
Newbie
Newbie


Joined: 25 Aug 2014
Location: United States
Online Status: Offline
Posts: 11
Quote tsh1586 Replybullet Posted: 11 Sep 2014 at 4:52am
maybe I'll just forget that column everything else is summing correctly!!!! Thanks for your help. I thought I was doing something weird but nothing I seemed to do helped.
IP IP Logged
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