Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data in a Previous Group

Status
Not open for further replies.

c0wt0wn1

Programmer
Feb 24, 2004
33
US
Hi...

I am using CR 8.5 and an SQL database.

This is the counter that I have currently in my reports. It works great. The first Number Variable is a Grand Total count. The second is a Group Total count that is reset after each group.

I would like the Group Total to leave out any prsnl_no that is recorded in the previous goup.


Code:
WhilePrintingRecords;

NumberVar TotalCounter := TotalCounter + 

If( not Isnull({gusd_person.prsnl_no})) and ({gusd_person.emp_stat} in ["A","I"])
//Employment Status... A=Active I=Inactive

then
    
If (Not isnull({gusd_person.prsnl_no})) and (PreviousIsNull({gusd_person.prsnl_no}) or {gusd_person.prsnl_no}<> Previous({gusd_person.prsnl_no})) 

Then

//This is where I would like it not to count anything 
//that is in the previous group.

Then
             
1
    
Else

0;





NumberVar MyGroupCounter := MyGroupCounter +

If( not Isnull({gusd_person.prsnl_no})) and ({gusd_person.emp_stat} in ["A","I"]) 

then  

If (Not isnull({gusd_person.prsnl_no})) and (PreviousIsNull({gusd_person.prsnl_no}) or {gusd_person.prsnl_no}<> Previous({gusd_person.prsnl_no})) 

then

//This is where I would like it not to count anything 
//that is in the previous group.

then
        
1
    
Else

0;

MyGroupCounter;
//Display the Group Counter

[\code]

I have tried and tried to create a formula using the Previous group but I can never seem to get it to work right. Any suggestions?

Thanks

-c0wt0wn1-
:-)MikeGose
 
Assuming the previous group may contain several different values, you need to load all these values into an array and check the values in the next group against that array.

hth,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Is there a way to make the array automatically pull up the information. Within my reports there can be up to 600 prsnl_no in the same group. This could be difficult to write all of them in.




Thanks... You gave me some new ideas!

-c0wt0wn1-
:)MikeGose
 
I've not tried but in VB syntax (IT'S PSEUDO CODE!)maybe you can use something like :
- init 2 arrays in report header, previousGroupArray and currentGroupArray
- in the group header adjust the size of the array based on the count of records in the group for the currentGroupArray:
Redim currentGroupArray(count(group))
- and init the position in the array:
position =0
- then in the detail section expert in suppress x-2:
-put in the array the value of the field:
currentGroupArray(position)=prsnl_no
-move position:
position=position+1
-check if prsnl_no was not in previous group
sizeOfpreviousGroupArray =ubound(previousGroupArray )-lbound(previousGroupArray )
hide_Detail=false
for n=0 to sizeOfpreviousGroupArray
if previousGroupArray(n)= prsnl_no then
hide_Detail=true
exit for
next n
hide_Detail

Then in the group Footer
move the values of the currentGroupArray to the previousGroupArray

This is pseudo-code you have to adapt it!

Anyway, this is a strange need. Are the group definitions correct as you are trying to hide records because they were in previous group?

In your code there are also a few problems, I Highlight them in the code below with my remarks in red:

Code:
WhilePrintingRecords;

NumberVar TotalCounter := TotalCounter + 

If( [highlight]not Isnull({gusd_person.prsnl_no})[/highlight]) and ({gusd_person.emp_stat} in ["A","I"])
//Employment Status... A=Active I=Inactive

then
    [COLOR=red]the second Not isnull statement(below) is useless as it's the same as before(highlighted upwards)[/color]
If ([highlight]Not isnull({gusd_person.prsnl_no})[/highlight]) and ([highlight]PreviousIsNull({gusd_person.prsnl_no}) or {gusd_person.prsnl_no}<> Previous({gusd_person.prsnl_no})[/highlight]) 
[COLOR=red]if Previous({gusd_person.prsnl_no}) is null the result is not predictable in the <> comparison which is made in this case. To avoid this write 
If (not (not PreviousIsNull({gusd_person.prsnl_no}) and {gusd_person.prsnl_no}= Previous({gusd_person.prsnl_no}))
This is because in a logical test with an and operator the right part is not calculated if the first part(on the left) is false [/color]

Then

//This is where I would like it not to count anything 
//that is in the previous group.

Then
             
1
    
Else

0;


MyGroupCounter;
//Display the Group Counter


django
bug exterminator
tips'n tricks addict
 
Thanks for all who attempted to help me out.

I am getting the answers I want with an array that I set up using the sample array from BusinessObjects' web site.
It works wonderfully. I will post the code tomorrow when I get to work so all can see.

Thanks again!



-c0wt0wn1-
:)MikeGose
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top