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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset After Group 1 Changes

Status
Not open for further replies.

Ohioste

Technical User
Apr 21, 2009
58
0
0
US
I have two groups in this report. I'm trying to find the number of errors made by a user.

My first group is the user, my second is the task. The task could have multiple detail lines so I've written the below formula:

whileprintingrecords;

booleanvar x;
numbervar y;


if Sum ({THAUDT00.THEXQT}, {THAUDT00.THPLN}) = Sum ({THAUDT00.THACQT}, {THAUDT00.THPLN})
then
x := false;

if Sum ({THAUDT00.THACQT}, {THAUDT00.THPLN}) <> Sum ({THAUDT00.THEXQT}, {THAUDT00.THPLN})
then y := y + 1;

y

It almost works, but it just keeps counting down the page anytime the second condition is met. How do I make the formula resett once a change of group is met.

Thanks in advance!
 
Nevermind...I made it a shared variable Y and then just made a reset formula.

Just had to take a step back...

Sorry.
 
Ok, so what I thought worked, only seemed to work about 80% of the time. I'm still using the formula above only I made my y variable a shared variable and set a reset for it in group header 1.

My y variable seems to work all the way through until my group footer 2. And again, it only works abotu 80% of the time.

My formula works perfect inside GH2 and allows me to put a total at the end of the report. I'm not sure what would cause it to work sometimes out of GF2 and then sometimes not. I've put the y value in GF1 and it shows the correct value, but it seems to increase by one. I can't find a common theme either of why it would make it on some and not on others.

Any help would be appreciated.
 
The "scope" (ie local/global/shared) only affects its availability through the report, and by omitting it, it becomes Global. Unless there is a sub-report involved which the variable needs to be passed to/from, making it a Shared variable is not required. In any event it will not make any difference in terms of whether a reset is required.

A couple of things to check:
[ul]
[li]The formula that sets the y variable is in the Group 2 Header or Footer only; [/li]
[li]You are not using Repeated Group Headers on new pages;[/li]
[/ul]

Please explain what you mean by "not woring". Some sample data may be useful.

Cheers
Pete
 
Also, it may not help but I have always found the results are more predictable if I include an "else" when setting variables. I would therefore amend the formulas as follows:

Code:
if 	Sum ({THAUDT00.THEXQT}, {THAUDT00.THPLN}) = Sum ({THAUDT00.THACQT}, {THAUDT00.THPLN}) 
then 	x := false
else	x := x
(or perhaps the last line should be "else x := true" - I am not sure how the result is being used so I am not certain which way to go)

and
Code:
if 	Sum ({THAUDT00.THACQT}, {THAUDT00.THPLN}) <> Sum ({THAUDT00.THEXQT}, {THAUDT00.THPLN}) 
then 	y := y + 1
else	y := y;

y

Cheers
Pete
 
Pete,

Appreciate the help! Unfortunately, I tried the new formulas and it still doesn't seem to be working properly.

Here are my formulas:

Code:
whileprintingrecords;

booleanvar x;
shared numbervar y;

if 	Sum ({THAUDT00.THEXQT}, {THAUDT00.THPLN}) = Sum ({THAUDT00.THACQT}, {THAUDT00.THPLN}) 
then 	x := false
else	x := x ;

if 	Sum ({THAUDT00.THACQT}, {THAUDT00.THPLN}) <> Sum ({THAUDT00.THEXQT}, {THAUDT00.THPLN}) 
then 	y := y + 1
else	y := y;

y

This formula is in the group header 2 line and then also a total on the group footer 1. Ideally, it should return the last number in GH2.

I'm resetting Y in every GH1 with this formula

Code:
shared numbervar y; 

y := 0

Any help would be appreciated.

Thanks!

 
So, what formula are you placing in the GF1 to show the Total?

And in what way is it not working? Sample data and results wold be helpful.

Do you have repeated Group Headings on subsequent pages?


Pete
 
I need to bring this back as I am now back temporarily on this account and this was not resolved while I was out.

The formula that is in my group footer is as follows:

Code:
whileprintingrecords;

booleanvar x;
shared numbervar y;

if 	Sum ({THAUDT00.THEXQT}, {THAUDT00.THPLN}) = Sum ({THAUDT00.THACQT}, {THAUDT00.THPLN}) 
then 	x := false
else	x := x ;

if 	Sum ({THAUDT00.THACQT}, {THAUDT00.THPLN}) <> Sum ({THAUDT00.THEXQT}, {THAUDT00.THPLN}) 
then 	y := y + 1
else	y := y;

y

The issue that I run into is that some instances a user will only have one task, an error on that task but it'll show two errors for that user. It does not happen for all users.

It's currently grouped by user(GH1) and task (GH2).

This is a picking application we are using are each task is a group of units we are picking.

The fields I'm using above are defined as:
({THAUDT00.THACQT}, {THAUDT00.THPLN}) = Actual qty summed by task
({THAUDT00.THEXQT}, {THAUDT00.THPLN}) = Expected qty summed by task

So if a user has 20 unit picks on a task, the expected qty will be 20. If they only pick 19, that will be the actual qty.

This should show a one unit error for this user and an error overall for this task.

I hate doing this, but I'm running out of options and if you need to see the report, my e-mail address is Ryan.Thompson@exel.com

Any help is appreciated.
 
Ok, I now know why that it's causing the number of some to inflate by one and not others.

If the last row of data for the formula above is true and it adds one, it will also add one in the group footer because it tries to evaluate the formula again.

The good news is I know why it's happening, the bad news is I don't know how to fix it....
 
I suspect you have the formula that increments the Variable "y" in the Group Footer as well as the Details section.

To display the Total in the GF, remove the existing formula and replace it with a new one like this:

Code:
whileprintingrecords;
shared numbervar y;

This will show the value of "y" without incrementing it again when the condition in the last record is met.

Hope this helps.

Cheers
Pete
 
Pete,

Appreciate the support. I had already tried this and it did not work.

An e-mail has been sent! Thank you again for your help.

Ryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top