Grouping data and saving to thing

I need to group data from a detail table that is in a range of dates and one other field for the data selection. There will be three data groupings and one aggregate. I need to save the data to a thing in order to use it in a repeating group that can then be exported as a csv.

What is the best way to accomplish this? I have tried everything I can think of and all I do is hit the wall