Maybe a pivot table is what you need?