This is a request from ticket 119080321000286. When trying to apply a group by of address1_stateorprovince field for a lead in the CDS connector for flow, it results in a 502 error. Per the ticket:
The same occurs on vanilla https://tp2sg901phxplain8413org1.crm10.dynamics.com/api/data/v9.0/leads?$apply=groupby%20((address1_stateorprovince)).
For all the individual fields for composite address like address1_city, address1_line1 etc. the behavior is same.
This is for other entities like contact and account also. This is by design.
Group by is not allowed on these fields.
The suggested work around is to add a new field and populate it with the data from the address field. This is a very poor work around for instances with a moderate to large number of records. Plus the 502 error is a horrible error for someone trying to get the group by to work.
My request is that the Group By would work on all address fields (or at least the city/state/zip).