Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Running Total, Evaluate on Formula & Group Chang Post Reply Post New Topic
Author Message
junkbox
Newbie
Newbie


Joined: 07 Nov 2012
Online Status: Offline
Posts: 17
Quote junkbox Replybullet Topic: Running Total, Evaluate on Formula & Group Chang
     Posted: 07 Nov 2012 at 11:01am
Sorry, not enough letters in title.

Should read "Running Total, evaluate on formula and reset on change of Group."

I've googled around a bit and can't seem to find a solid answer. I have two groups, we'll say 'Register' and 'Date'. In the details band, because of the way this view is setup, the details band will repeat. I have no control over software or the database and I don't believe it could be fixed if I did. This being said, I need some running totals going which I've mostly sorted out.
What's happening is that in order to get around the repeated numbers which I need to only sum unique values I have created a running total for let's say FOOD.
So I made FOOD_TOTAL which sums. The evaluation is a formula namely:
NOT({dbo.sales.foodtotal}=Previous({dbo.sales.foodtotal}))

Then I'm resetting on change of group 'Date'

Anyway that's my logic on this. OK well it kinda works. The problem is, and what I can't wrap my skull around is why all of the groups except the first one displays the running total correctly (blank). I can kinda understand except the same formula/total works if there's not two groups. So I'm thinking Crystal somehow is confusing itself if because of the multiple groups.

So for giggles, I change the above formula to:
{dbo.sales.foodtotal}<>NEXT({dbo.sales.foodtotal})


This produced the exact opposite results. All groups display the running total except the last group now. So depending on which of the formula I use, I lose the last or first running total.

So I get it, the evaluation breaks on two groups depending on the evaluation 'direction'. But certainly CRXI should understand that because I'm explicitly asking to reset on group and only eliminating details from the total that I would want the first or last group included in the total.

Am I missing something?

Thanks.

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Nov 2012 at 12:04pm
onfirstrecord
or
NOT({dbo.sales.foodtotal}=Previous({dbo.sales.foodtotal}))
IP IP Logged
junkbox
Newbie
Newbie


Joined: 07 Nov 2012
Online Status: Offline
Posts: 17
Quote junkbox Replybullet Posted: 07 Nov 2012 at 1:04pm
hmm...well OK srsly Crystal? I'm baffled neither of the formulas up top would work, but a combination of the two does?

NOT({dbo.sales.foodtotal}=Previous({dbo.sales.foodtotal})) OR {dbo.sales.foodtotal}<>NEXT({dbo.sales.foodtotal})


I'm not even sure I want to know why it works Confused

anyway I hope this saves someone some time when Rtotaling on duplicate details.
IP IP Logged
junkbox
Newbie
Newbie


Joined: 07 Nov 2012
Online Status: Offline
Posts: 17
Quote junkbox Replybullet Posted: 07 Nov 2012 at 1:07pm
Originally posted by DBlank

onfirstrecord
or
NOT({dbo.sales.foodtotal}=Previous({dbo.sales.foodtotal}))



right i had tried that first and but receiving blanks on the first group.

Any idea why my above post would work...logically I mean when neither NOT(previous) nor <>Next wouldn't by themselves?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Nov 2012 at 2:07pm
It has to do with how crystal handles nulls.
Using previous and next can ignore the first or last row in the data set because the previous or next value is null. If you do not tell crystal how to handle the null it won't evaluate the formula at all.
You likely could also use your original formula the pick list option of 'default vales for nulls' and it would rectify the issue.
IP IP Logged
junkbox
Newbie
Newbie


Joined: 07 Nov 2012
Online Status: Offline
Posts: 17
Quote junkbox Replybullet Posted: 16 Nov 2012 at 6:52am
oh, excellent tip DBlank, thank you. I'll clean up the formula then and use that.
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