spyr0
spyr0

Reputation: 199

Check last record of each group

My formula needs to detect when it reaches the last record in a group before the group changes. I tried using both OnLastRecord and creating a running total field (which resets on change of group) to do this. In both cases it only checks the very last record on the very last page of the report.

My ultimate goal is that I want my report to check if a number field, {@Calc} on the last record is < 0. If so output "Outsanding:" &{@Calc}*-1.

Upvotes: 1

Views: 8657

Answers (2)

spyr0
spyr0

Reputation: 199

I have figured out my problem. I am now using:

{grouped field} <> next({grouped field})

which gives the value of last record for each group value.

Upvotes: 3

4444
4444

Reputation: 3680

Have you considered using the Group Footer for the group in question?

When you reach that particular footer, the active record will be the last one in the group. So any calculations you perform, or any fields you choose to print, will be based on the final record read in that group.


Note: If you're suppressing some records in the group, this might not work. In which case, you can instead use Shared Variables to store the latest valid value for Calc.

Then by the time you reach the footer, you can check to see if the variable is less than zero and display your Outstanding field based on the result.

Upvotes: 1

Related Questions