How do I set minimum value to the calculated result?