Calculate total sum per category