How to group by multiple keys (x, y, z)

Hi!
I am trying to do something similar. I want to group the columns in the same location (x==x, y==y, but z can be different).
With your help I already did the groups but now I need to know how to give the same name to the elements of each group.