Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Creating a summary of a second pass formula Post Reply Post New Topic
Author Message
kmeistering
Newbie
Newbie


Joined: 19 May 2010
Location: United States
Online Status: Offline
Posts: 10
Quote kmeistering Replybullet Topic: Creating a summary of a second pass formula
     Posted: 13 Oct 2010 at 3:04am
Hello,

I am not sure why, but some duplicate data is showing up in my report even though I have chosen to select only distinct records and the data is not found more than once in the datasource.  Additionally, I'm working to make it so this report can be run directly from my original data, and there is some duplication there (for instance, if someone is employed at 25% in one area and 75% in another area, it will list their total combined salary under each position.)

I have found a way to get rid of these created duplicates through the following formula:

If (({Main_Data.Position}) = previous({Main_Data.Position}))
and (({Main_Data.Enc Sal Amt}) = previous({Main_Data.Enc Sal Amt}))
then $0 else ({Main_Data.Enc Sal Amt})

However, since this is a second pass formula, I am not able to create a summary of this field or a running total.  I've been trying to figure out how to summarize it in the formula so it will also happen in the second pass but have come up blank.

I am willing to use something else if I can get rid of my duplicates in some other way, but I need to summarize these fields!

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 13 Oct 2010 at 3:29am
shared variables...
 
3 formulas
1) reset (usually in group header):
shared numbervar aVar :=0;
""//to hide the output
 
2) increment (usually in details)
shared numbervar aVar;
aVar := aVar + {table.field} //maybe there is a condition...so inside the if
"" //hide output if desired (for a 'running total' remove
 
3) display (usually in group footer)
shared numbervar aVar
 
HTH
IP IP Logged
kmeistering
Newbie
Newbie


Joined: 19 May 2010
Location: United States
Online Status: Offline
Posts: 10
Quote kmeistering Replybullet Posted: 13 Oct 2010 at 3:36am
I'm not super familiar with shared variables - is what you have typed exactly what I need to put in the formulas? 
IP IP Logged
kmeistering
Newbie
Newbie


Joined: 19 May 2010
Location: United States
Online Status: Offline
Posts: 10
Quote kmeistering Replybullet Posted: 13 Oct 2010 at 3:54am
Also, please note that I do not have a subreport - my second pass formula is in the main report.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 13 Oct 2010 at 8:12am
pretty much... you can change the names and add conditions, but the syntax is correct. 
 
I like shared variables just because it is easier for me to remember than global (and for some reason it is easier to type).  shared will work just as well as global with or without the subreport, but global won't work for the subreport....so I choose shared as a generic catchall.
 
 
HTH
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