Hey @tomm,
not a problem, happy to help (besides I've been there too not long ago and this forum helped a lot!).
So, the way I would approach it is to create nested arrays within one "record", and group each record by a common denominator, which in this case it seems to be the carrier.
I usually do this with my SQL query like this:
SELECT
field1,
field2,
field3,
field4,
json_agg(
json_build_object(
'field5', field5,
'field6', field6,
'field7', field7,
'field8', field8
)
) AS shipments
FROM shipping
WHERE ship_date = {{moment(new Date())}}
GROUP BY field1, field2, field3, field4
ORDER BY field1, field2
This should give you one record for each Carrier/Address with nested arrays for each shipment that fall under the same group.
Another way is to use a "Query JSON with SQL" resource where you can basically do the same, i.e. group records and nest records within them by building arrays. You would have your main query, and then use the second query json with sql resource to structure the data from the main query.
This is the structure I've used for this kind of resource (apologies for not removing context from my own app):
SELECT
product_name,
id,
product_type,
business_unit_id,
default_monthly_cost,
currency,
ARRAY(
@{
lead_id: (lead_id),
lead_value: (lead_value),
lead_currency: (lead_currency),
active: (active),
ongoing_programs_count: (ongoing_programs_count),
opportunity_name: (opportunity_name),
stage_id: (stage_id),
stage_name: (stage_name),
funnel_name: (funnel_name)
}
) AS details
FROM {{getProductStats.data}}
GROUP BY
product_name,
business_unit_id,
id,
product_type,
default_monthly_cost,
currency
ORDER BY
name
With regards to the UI, I think you will need a nested listview within your parent listView. With the same logic, the parent listView holds the main records with data source being query1.data, and the nested listView is for yoru records, with the datasource being item.shipments (as it is a nested listView you can use item to refer to the whole record).
Hope this helps as guidance. Keep throwing your questions if you get stuck!