Need help converting this logic into a sumproduct type of formula