I have a transactional dataset (Table
). I want to identify rows that have the same ID and have amounts that are voided (or canceled). Basically what I want is a new column, "Voided", that looks something like:
ID Amount Voided
1001 10 1
1001 -10 1
1001 -10 0
1002 25 0
1002 25 0
1003 20 0
I've tried the following code as a new column:
Voided =
VAR void =
COUNTROWS ( FILTER ( ALL ( Table' ),
'Table'[ID] = EARLIER ( 'Table'[ID] )
&& ( 'Table'[Amount] = ( -1*(EARLIER ( 'Table'[Amount] )))
|| 'Table'[Amount] = ( 1*(EARLIER ( 'Table'[Amount] )))
)
))
RETURN IF ( void >= 2, 1, 0 )
However, this doesn't work because I end up with the following:
ID Amount Voided
1001 10 1
1001 -10 1
1001 -10 1
1002 25 1
1002 25 1
1003 20 0