Show Hide SubTotal on Grouping

Hello,

In our Report we have multiple currencies and we have to show Total only if there is common currency, if the currency is different total should not be shown. I have fixed this issues in the Normal grid, works in both filter and without filter cases. Have used a Global Variable in the in the SQL.

But my issue comes in the case of Grouping, as i have figured out the grouping works completely differently and has its own Events.

I have figured out that in on_GroupByAll event all the filters come in this variable => $Where_qb.

To implement the group by filter i have created another global variable and put that in sql condition.

But unfortunately this filter is for the previous grouping not for the current grouping.

Can someone please help me in this matter.