Is :groupby unavailable for Option Set attributes?

I need to group by the “Display” attribute of Options in a list, but the :groupby operator seems to be unavailable.

For context, I have a custom data type called “Message”. Each Message can contain a list of “Petitions” (“Petition” is another custom data type). Within each Petition there is a list of “Topics” (“Topics” are an Option Set).

I’m running a search to find all the “Topics” associated with a specific list of Petitions, where that list of Petitions is associated with a specific list of Messages. I need to group the “Display” values of all the Topics, so that I can count how many times each distinct Display value appears in the list, and then use those counts in a chart.

For reasons I can’t figure out from the reference or the forum posts, when I try to run :groupby on the list of Display values (or any other attribute associated with Topics, for that matter), the :groupby operator is not available among the dropdown options when I try to build the search dynamically.

I’ve been able to use the :groupby operator to build arrays of counts on various data types without a problem, so I’m wondering if the issue in this case is related to the fact that the list consists of Options instead.

Has anyone else experienced something similar, and if so, is there a workaround?

Yes. I think many of us have run into this sort of limitation in the past - you’re looking for a command, but it’s not available in a specific context (for example, a lot of commands only exist at the element level, but are not available for objects or vice-versa). Best solution is to find a different way to do it. that’s vague, but it’s what i’ve done in the past.

Thanks for the background.

I’m open to suggestions if anyone has any ideas as to how I can implement a workaround that would let me replicate the results of a :groupby operation on a list of values derived from a specific Option attribute.