Group by with list

I have a type called Elements:

  • name (text)
  • calls (type Call. It is a list of calls)

and another type Calls:

  • different fields here

I want a group by where I aggregate as follows:

for each Element’s name I want the count of calls in the list.

group by element.name count(calls)

Please help

I can’t use a backend workflow to store this in the database because I want the next step for this to be dynamic where I filter on the list of calls to be in a specified date range

Is the call-element relationship a many-to-one or a many-to-many?
(Does every call belong to a single element or can a call be in many elements at once?)

a call can be in many elements

I have a workaround but it means creating an added datatype with element-call as the primary key. It just seems like a waste to have this table like this so I’m hoping there’s a way of using the group by in the list

Sadly the bubble :group by operator is not as versatile as its Python/JS counterpart.
You cant really use it how you envision it because it does not return the grouped dataThings. It just returns two lists; grouping names and aggregation values. So the dataThings don’t get returned at all, and you wouldn’t be able to filter.

Try implementing this instead:
Elements: formatted as text [Content to show per list item= This element's calls: filtered (Constraint: This call's date is in DateRange) :count]

I dont think this would be particularly fast if you feed it a lot of data, but it should return a list with the counts.

This topic was automatically closed after 70 days. New replies are no longer allowed.