dynamically build the filter for an aggregate

dynamically build the filter for an aggregate

So what I would like to do is dynamically build a filter for an aggregate so I can take advantage of the grouping and calculated fields in an aggregate. So say I have a list of tool usages. The user, on the page, will enter a list of tools they want to include in the report. I want to take that list of tools the user builds (the tool ID) and use that for my filter in my aggregate. Is there a way to do this?

say I have a data table which is tool usage and it contains a start time, end time and tool id. The user at the page can select multiple tools that they want to see a table of. In the aggregate I want to do some grouping and calculated fields and sorting. So if I do a separate aggregate for each tool they selected and then append them together then the grouping and calculated fields won't work (as I understand it). So what I want to do is in the aggregate use the list of tools selected to filter the aggregate. Is that possible?

So for all the grouping and calculated fields that I am going to make for the "easy" aggregate, is there a way I could set that up for 1 piece of equipment and then see the SQL query for it that its actually running, copy and then paste that into the advanced query? In other words use the easy interface to make the aggregate then copy and past the resulting SQL query into the advanced query then just replace the equipment id with what the user is inputting?