There is a typo in the formula - the 1+MAX(...) should be encased within parentheses - ie (1+MAX(...)) ... also I used C3 as the amount rather than D3 - alter as necessary.