Help with Data Format Keyed Array

With the series key, I assume this is for charting. We have used RunJS to get the data in the format we want.
First we used custom query to write a query that could return as close of a structure as possible, and then use RunJS to get the final JSON data.

I don’t have an exact code to share with you, but nested loops should help you get the data structure you want.