# Formula based on criteria?

✭✭✭✭

I have no idea if this is possible, it seems like it should be. I want to calculate the difference between two cells, but only when both cells have values, otherwise the cell should remain blank.

So if "January Spending" has a value (Cell B), then it should be subtracted from the "Estimated Monthly Spending" (Cell A) - this calculation would be placed in Cell C. Otherwise, Cell C should remain blank.

Tags:

• ✭✭✭✭✭✭

Try this:

=IF(AND(January46 <> "", Description57 <> ""), January46 - Description57)

• ✭✭✭✭✭✭

@Sam C It can be done, try something like this and see if it works out.... if( January Spending <> "", Estimated Monthly Spending@row-January Spending@row , "" )

• ✭✭✭✭

I'm getting an Incorrect Argument error

"January46" is "January Spending" (sum formula) and "Description" is the "Estimated Money Spending" (average formula)

=IF(January46 <> "", Description@row, January46 - Description@row, "")

I also tried this one but got the same error

=IF(January46 <> "", Description57, January46 - Description57, "")

• ✭✭✭✭✭✭

Try this:

=IF(AND(January46 <> "", Description57 <> ""), January46 - Description57)

• ✭✭✭✭

That worked like magic. Thank you!

• ✭✭✭✭✭✭

Happy to help. 👍️

## Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!