Within a chart you can refer to previously set expressions in subsequen expressions by their name in square brackets. eg if expression 1 is called A and expression 2 is called B you can refer to them with [A] and [B].
You have nearly answered your own question there.
Use an if statement to compare the two:
if([ABC] = [DEF],'OK','ERROR')
Is this what you are after?