Previous Formula Check

I'm trying to use the previous function to check to see if I have duplicate departments in my detail.

my formula is : if dept = previous(dept) then 1 else 0

I though that by using the previous formula, I would get whats listed in the expect result.
Can you guys help me get the expected result by either using the previous command or something else.

Thanks

This is what I currently have:

Dept      DupCheck       Expected Result
01000    1                     0
01000    1                     1
01200    1                     0
01200    1                     1
Who is Participating?

Commented:
What are you trying to total?

Try this

WhilePrintingRecords;
Global numberVar DuplicateTotal;
DuplicateTotal := 0;
""

WhilePrintingRecords;
Global numberVar DuplicateTotal;

If Not OnFirstRecord AND {Dept} = Previous({Dept}) then
DuplicateTotal :=DuplicateTotal + 1;
""

In the report footer to display the number of duplicates
WhilePrintingRecords;
Global numberVar DuplicateTotal;

mlmcc
0

Author Commented:
I got the formula to work:
if next({dept.ACCT_UNIT}) <> previous({dept.ACCT_UNIT}) then 1 else 0

Problem I get now is that I can't use it to evaluate my running total.
I get the following error message:
Running Total cannot refer to a print time formula.

Does anyone have any suggestion as to how I can correct this?
0

Commented:
FWIW, your original formula looks OK (except that it should check OnFirstRecord, like in mlmcc's formula).  I don't see how that formula could give you 1 on the first 01200 line.

OTOH, your second formula, with Next <> Previous doesn't really make sense, because it's not even looking at the current record.

Anyway, like mlmcc said, what are you trying to total (in your running total)?

If you just want to know if there are duplicates, or how many there are, you could use Count ({dept.ACCT_UNIT}) and DistinctCount ({dept.ACCT_UNIT}).

If you're trying to total some fields and only want to add them once for each "duplicate" record, there are ways to handle that.  For example, if the records are sorted by {dept.ACCT_UNIT}, you could have a running total evaluate "On change of" {dept.ACCT_UNIT}, so it only adds to the total when that field changes.

James
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.