Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help with Formulas - summation Post Reply Post New Topic
Author Message
tjbarr63
Newbie
Newbie


Joined: 14 Apr 2014
Online Status: Offline
Posts: 3
Quote tjbarr63 Replybullet Topic: Help with Formulas - summation
     Posted: 14 Apr 2014 at 6:44am
I have 2 formula's in my crystal report. One of them decides what gifttype to use and the other decides if they are part of a certain group with a yes or no. If I just have output id and Formula 1 then my gift calculations are correct.

If I just have id and formula 2 then my formula 2 yes and no's are correct.

If I try to use both formula's then formula 2 yes and no's are correct but formula 1 gift calculations are multiplied by the total amount of attrtypes the id has associated with them, even if they are not one of the selected yes's.


Formula 1 (which is summed)

If {GIFT_TYPES.TABLE_CODE} = "g" then {GIFTS_FULL.GIFTAMOUNT}
else if {GIFT_TYPES.TABLE_CODE} = "c" then {GIFTS_FULL.GIFTAMOUNT}
else if {GIFT_TYPES.TABLE_CODE} = "p" then {GIFTS_FULL.GIFTAMTPLG}
else if {GIFT_TYPES.TABLE_CODE} = "e" then {GIFTS_FULL.GIFTAMTPLG}
else if {GIFT_TYPES.TABLE_CODE} = "r" then {GIFTS_FULL.GIFTAMTPLG}
else 0

Formula 2:

If ({attribute_full.attrtype} = "LSVT" or {attribute_full.attrtype} = "BVC" or {attribute_full.attrtype} = "SVC"
     or {attribute_full.attrtype} = "EVC" or {attribute_full.attrtype} = "ENVC" or {attribute_full.attrtype} = "AVC"
     or {attribute_full.attrtype} = "ASVC" or {attribute_full.attrtype} = "SVC" or {attribute_full.attrtype} = "UVC"
     or {attribute_full.attrtype} = "VCCE" or {attribute_full.attrtype} = "BOT" or {attribute_full.attrtype} = "FBoD"
    ) then 'Y' else 'N'
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Apr 2014 at 6:57am
Likely has to do with your joins and when crystal enforces them.
you will see the same thing happen just by using any field from all the tables in your data set or if you go into the jouins and set them all to 'enforced'.
IP IP Logged
tjbarr63
Newbie
Newbie


Joined: 14 Apr 2014
Online Status: Offline
Posts: 3
Quote tjbarr63 Replybullet Posted: 14 Apr 2014 at 7:12am
Right now they are all set at not enforced.
My joins are left outer joins from a basic table to both the attribute_full and gifts_full table.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Apr 2014 at 7:23am

In crystal, if your joins are not set to enforced your data set can change as you start using fields from each table which then enforces the joins.

Get your joins enforced and look at your actual data set to see what kind of rows you are dealing with.
IP IP Logged
tjbarr63
Newbie
Newbie


Joined: 14 Apr 2014
Online Status: Offline
Posts: 3
Quote tjbarr63 Replybullet Posted: 26 Apr 2014 at 8:52am
I enforced all the joins and am still having the problem. Help!
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 28 Apr 2014 at 8:37am
DBlank didn't mean that enforcing the joins would fix the issue, rather that it would reveal that the joins are the source of the problem. You need to look at how your tables are joined to each other to fix the problem. Are you sure you have the correct fields joined to each other? If so, try changing the join type to see if the problem resolves itself.
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