How to calculate items to get total value