I you are able to re-arange your data, you can use pivot table for that.