Joinaggregate and argmax() using transform

Hi,

I am trying to display the count of container for each state

example:

container_id, container_state, timestamp
1, loaded, 2pm
1, received, 4pm

here the count of container_id 1 should be only for received state because container is no longer in loaded state

2, received, 5pm
3, loaded , 2pm
4, received, 2pm
4, loaded , 5pm
5, loaded, 3pm

container_state count
Loaded 3
Received 2

so total there are 5 containers out of which 3 are currently in loaded state and 2 are in received state.

I am trying to use vega-lite and using transform, if I get the most recent actionTime for each container_id, how do I join this to the container state and display count of all the container_id per current state of the container.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "title": "Total volume per state of container",
  "data": {"url": {"index": "my_index12_2020-11-08"}},
  "transform": [
    {
      "aggregate": [
        {"op": "argmax", "field": "actionTime", "as": "argmax_actionTime"}
      ],
      "groupby": ["currDetails_container_id"]
    }
  ],
  "mark": "bar",
  "encoding": {
    "x": {"field": "argmax_actionTime['currDetails_container_id']", "type": "quantitative"},
    "y": {"field": "currDetails_state", "type": "nominal"}
  }
}

I see that you've asked a similar question already. Let's move discussion to that thread. Using rank and partition in vega-lite

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.