A FOR NEXT loop probably shows really bad performance. I must admit I haven't fully understood the way you create your aggregates (store the top most row?), I think a copy of your script would really help me understanding this.
Have you already tried a GROUP BY LOAD of your table to create your aggregates? How does this perform?
You may still need to create the cross product table to get a table with all combinations, but then you just need to LEFT JOIN this table with your aggregation table and maybe go through the table once more to fill in zero values.