Total quantity calculation

Hi,
I would like to calculate total number of medicine , already sent to a health worker.

For example:

Day 1, 10 paracetamol packs was sent to the Clinic. Type in quantity 10 packs
On the case
Detail , I want to display Total Quantity = 10 packs

Day 2, 20 paracetamol packs was sent to clinic. type quantity 20.
Total Quantity Display = 30 Packs

Day 3, 5 packs are sent again. type quantity 5. Total Quantity display= 35 packs… etc.

How can I do this using CommCare? I tried with sum function but it's doesn't work.
And also would like to add medicine and reduces medicine from original quantity.

Best Regards
Lin