Creating formulas using testing for conditions