How to use quantity in calculation