Running total (cumulative sum) by date

Get it! thanks for the example it made me have the whole idea fastly. Unfortunately I think that’s not possible. It is possible by GroupBy but you would need to create a ““kind of edge calendar based structure”” to work.

And about the accumulation that you would have to do via application (your app). For it is not possible to do cumulative aggregation with time parameters. You can do it, but each parameter would have to be done manually.

In fact you can even do something with GroupBy.

{
  q(func: has(a.acquired)) @groupby(a.acquired) {
      Total : count(uid)
    }
}

Result

{
  "data": {
    "q": [
      {
            "@groupby": [
              {
                "a.acquired": "2018-02-14T00:00:00Z",
                "Total": 1
              },
              {
                "a.acquired": "2018-03-01T00:00:00Z",
                "Total": 1
              },
              {
                "a.acquired": "2018-06-04T00:00:00Z",
                "Total": 1
              },
              {
                "a.acquired": "2018-01-28T00:00:00Z",
                "Total": 2
              }
            ]
      }
    ]
  }

But I do not think it’s ideal. Well you can not do much with this grouping for other blocks. It may be useful for the final application, but not for applying other GraphQL +- logic.

1 Like