How to dynamically add conditions or filters to aggregate query

@Saravana_Srinivasan, I provided a potential solution more than a week ago.

If you

I will appreciate that you mark my post as the solution so that others know that it works.

If it does not, please share the issues you encountered.