Applying additional formulas to rollups or the equivalent

I want to be able to apply a calculation to a rollup but it isn’t available out of the box. What would be the equivalent of this in glide?
I imagined that I might be able to add additional formulas to rollups but this doesn’t seem possible.

I know I can calculate the average of values in a rollup

In this case, I want to calculate the sum of the two highest values in my rollup.

You’d have to combine a few columns. Perhaps something like:

  • Use a lookup through the associated relation to get an array of all values
  • Sort the array using the array sort plugin
  • Use two single value columns to pick out the last two items
  • Sum those using a math column

If you know JavaScript, then a more efficient way would be to grab a joined list of all values through the arrayrelation, and then process that with a JavaScript column.

Interesting… didn’t know about the javascript column. Thanks @Darren_Murphy still on the learning curve.

Thanks @Darren_Murphy… ended up using a javascript column to do the final manipulation.