Google Sheets – How to Nest a Function Within a Logical Statement

google sheets

Is it possible to include a formula as the value_if_true within a logical statement in a cell in Google sheets? For instance, I would like to subtract the two rightmost digits in two adjacent cells, if that value in E23 is greater than the value in D23. I know how to return a yes or no:

=IF(RIGHT(E23,2)>RIGHT(D23,2),"YES","NO")

but can I perform an operation if the value is true? I've (blindly) tried:

 =IF(RIGHT(E23,2)>RIGHT(D23,2),=RIGHT(E23,2)-RIGHT(D23,2),"NO")

but of course, that returns an error. How would I perform the equivalent of that function for a true value?

Best Answer

=IF(RIGHT(E23,2)>RIGHT(D23,2),RIGHT(E23,2)-RIGHT(D23,2),"NO")

"=" not required inside if statement.