Skip to main content

Compare a record with a previous record

Hi,
For some reason unkown some bank export files contains double records. All the fields are character fields. I created two virtual character fields, one with all the character fields of the current records combined. The second virtual character field contains all the character fields of the previous record by using the @GetPreviousValue function. Then i created a virtual numeric field which contains a @If function which results in 1 if both virtual character fields are equal and 0 if not. For some reason i don't understand i don't get any results that the virtual character fields in some cases are equal. When i do this check in Excel with the CONCATENATE function i get results that in some cases the prevision and current record are equal. What i noticed is that when using the GetPreviousValue function the field name needs to be within quatations for example: GetPreviousValue("MSGID") . Does anyone has een idea what could be going wrong?

Brian Element Fri, 08/30/2019 - 09:49

Hi Robert,

I think it is a limitation of the @GetPreviousValue function.  In the documentation it says:

Virtual fields that have been appended using @GetNextValue should not be indexed or used as a Control Total field.

Doesn't quite relate to you but it gives me an idea that the comparison doesn't work.  Instead why don't you do the comparison directly such as:

@if(@GetNextValue("FIELD1") == FIELD1 .AND. @GetNextValue("FIELD2") == FIELD2, 1, 0)

I didn't test this out but since you are doing a direct comparison I think it would.

There are a couple of functions that need the field names in double quotes, these functions are referencing the fields but not directly in the same row, that is why the double quotes, the other one that uses that is the @FieldStatistics() function. 

Brian