Hello John, and welcome,
Looking at your data, I'd be tempted to use an append template to pull in the TYPE, as well as the DETAIL, and then compare the two fields to distinguish payments from invoices.
But if you're working from a table of data instead of from a report, that might be a bit fiddly. The problem is that Monarch won't let you make fomulae that refer to other rows of data - so:
is impossible, as B2 is data from another row.
Two tricks - if it's a report, use an append template. If you're working in a table, use Recno()1 or Rowno()1 and export this, then look it up joining on Recno() or Rowno().
As Olly stated, if this is a table it's a no go. However, as he also stated if this is a report, there are many options. Olly's will work, so would trapping and using the option 'copy value from previous record if it is blank'. Either will working a report.
If it's a table and you still want to accomplish this, you can import the table into Monarch, export it as a text (any type of report file) and read that through another pass in Monarch.