Pivot tables can only be used with aggregated queries


How to use pivot tables with Sql query?

Do first a sql query and then a gui question that uses the sql query as the source and make the pivot table

But,I can't add the date filter in a gui question, because the sql query is aggregated result (equipment data ) grouped by color and region.
The requirement is that I can filter data for a period of time,then use this data to goup by region and color and corresponding propotion.