Sort organizations by number of facilities in fetch

#1

I’m looking to fetch all organizations and sort by the number of facilities associated with that organization (in C3 Energy Management).

Assume this is something like
c3Grid(Organization.fetch({
order: “descending(??)”
}))

Any guidance appreciated!

#2

I would try with evaluate, for instance:

c3Grid(Organization.evaluate({
  projection: 'name, count(denormFacilities)',
  group: 'name',
  order: 'count(denormFacilities)'
}))
1 Like
#3

You could add a stored calc field on Organization and order by that.

1 Like