Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Summation Issue at the Group Footer Post Reply Post New Topic
Author Message
vijayk
Groupie
Groupie


Joined: 14 Mar 2007
Location: United States
Online Status: Offline
Posts: 53
Quote vijayk Replybullet Topic: Summation Issue at the Group Footer
     Posted: 25 Mar 2008 at 10:37am
Hi ,
 
I have a scenario where I dont want to add the gross amounts of the records if the previous record has the same Rec No value as the current record in the group footer
 
Detail records will be something similar to this
 
State     City   Rec No Gross Amount
 
MI         Detroit      1111     100$
MI         FI              1111     100$
 
GroupFooter ( Grouped on State )
 
Sum of Gross Amount Field should only display 100$ instead of 200$.
 
Thanks
Vijay
 
 
      
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 25 Mar 2008 at 9:01pm
You need a custom running total field. Use the PreviousValue() function to compare the current Rec No to the previous Rec No. If they are different then add it to the Global variable. In the Group Header, reset the Global variable back to zero.

Then main running total formula would be something like this:
Global NumberVar TotalAmount;
if {table.Rec No} <> PreviousValue({table.Rec No}) then
   TotalAmount := TotalAmount + {table.Amount};

I cover custom running totals in detail in Chapter 3 of my book. You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.

Edited by BrianBischof - 25 Mar 2008 at 9:04pm
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
vijayk
Groupie
Groupie


Joined: 14 Mar 2007
Location: United States
Online Status: Offline
Posts: 53
Quote vijayk Replybullet Posted: 26 Mar 2008 at 7:28am
Thanks Brian..! It worked like a champ.
 
Vijay
IP IP Logged
vijayk
Groupie
Groupie


Joined: 14 Mar 2007
Location: United States
Online Status: Offline
Posts: 53
Quote vijayk Replybullet Posted: 27 Mar 2008 at 8:23am
Brian,
 
I think i have one more issue. I dont have to compare the whole record but I have to compare multiple columns in a record. It works if i do for one column. below is the code
 
I created a Running total field and under evaulate, I used use a formula and my formula looks like this
 
Previous({@DeleteNo}) <> {@DeleteNo}
 
It works fine if i do this. I just wanted to add one more column to it and created some thing like
 
(Previous({@DeleteNo}) <> {@DeleteNo}) and (Previous({@GrossAmoumt}) <> {@GrossAmount})
 
But it doesnt work. It still displays the same result set as the first one.
 
Can i create complex conditions under use a formula in Evaluate section. If so, Do you see any issue with my code.
 
 
Thanks
Vijay
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 27 Mar 2008 at 10:52am
Yes, you can create very complex formulas in the Evaluate section. The problem is getting the logic to those formulas working! 

However, the formula looks fine to me. Do you want it to skip the test when BOTH fields are the same as the previous record or only when either field is the same? Right now it should be doing it for both of them. You can use an "OR" operator to make it either field.

Does that help?
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
vijayk
Groupie
Groupie


Joined: 14 Mar 2007
Location: United States
Online Status: Offline
Posts: 53
Quote vijayk Replybullet Posted: 27 Mar 2008 at 11:05am

I needed to look for both the conditions so what i did was combined both fields and used that in the formula section and it works perfectly. Thanks much.!

Vijay
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