When printing a report for A/R Invoices, how do I get a value from a batch different from the current batch?

SOLVED

I need to add a summary section to my invoice report with the value of the invoice from the previous year (if there is one).

I plan on storing the batch number for the previous years invoices in the invoice optional fields.

Here’s my formula to get the batch number called: @lastYearBatch

If ({ARIBHO.OPTFIELD} = "LASTFINALBATCH")

THEN {ARIBHO.VALUE}

Else ""

How do I select "ARIBH"."AMTINVCTOT" where "ARIBH"."CNTBTCH" equals @lastYearBatch ?