Expression for grouping by matrix

Can I add the expression for Grouping by matrix in the query section?
For reference this is where I want to add the expression:


And the transformation I am talking about is: