I've created a deneb visual where I have a summary aggregation that sums durations by status color. I would like to join/concatenate the statusses belonging to the same color to show as tooltip in the visual.
Given an example dataset of:
Color | Status | Duration |
---|---|---|
red | Pause | 120 |
red | Offline | 30 |
green | Busy | 41 |
blue | Waiting | 32 |
blue | WrapUp | 230 |
blue | Call | 321 |
I would like to do an aggregate like this:
Color | Status | Duration |
---|---|---|
red | Pause, Offline | 150 |
green | Busy | 41 |
blue | Waiting, WrapUp, Call | 583 |
There is a join expression (join(array[, separator]) ≥ 5.3) that I thought could help me out here but according to the docs its >5.3. I cannot seem to get that expression to work with my dataset apart from using literal values:
join([1,2,3], ',')
I have the impression I'm looking over something obvious here as this shouldn't be too difficult of a transform. Any ideas?
Keep in mind this is Vega not Vega-Lite.
Here you go.
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"data": [
{
"name": "table",
"values": [
{"Color": "red", "Status": "Pause", "Duration": 120},
{"Color": "red", "Status": "Offline", "Duration": 30},
{"Color": "green", "Status": "Busy", "Duration": 41},
{"Color": "blue", "Status": "Waiting", "Duration": 32},
{"Color": "blue", "Status": "WrapUp", "Duration": 230},
{"Color": "blue", "Status": "Call", "Duration": 321}
],
"transform": [
{
"type": "aggregate",
"groupby":["Color"],
"fields": ["Status", "Duration"],
"ops": ["values", "sum"],
"as": ["Status", "Duration"]
},
{"type": "formula", "as": "Status", "expr": "pluck(datum.Status, 'Status')"}
]
}
]
}