How to compare different field values with conditional logic