Using "Math" aggregation and "Group by filter" together in Visual Builder

I have the data coming in the format (simplified for clarity):

   "@timestamp": date,
   "order": {
      "status": string,
      "price": float

Now, I want to make a time series plot that sums up the order.price separately for order.status: completed and order.status: cancelled, but the latter should be plotted as a negative value.

Due to the fact that the graph is shared with other metrics, I am forced to use the right y-axis. The plan is to have just one axis for order.status: completed and order.status: cancelled plotting the values above and below the x-axis, respectively. That is why I cannot split the data into two series or I'd get two y-axis.

It is the negative value for order.status: cancelled that I am struggling with. The series stricture:

  • Aggregation (Sum of order.price)
  • Group by (Filters order.status: completed / order.status: cancelled)
    produces the graph with two curves but both of positive values.

The series

  • Aggregation (Sum of order.price)
  • Aggregation (var price: Sum of order.price; Expression: params.price * -1)
  • Group by (Filters order.status: completed / order.status: cancelled)
    makes both curves to be of negative values.

And I cannot pass as Math parameter anything but a number, i.e. I cannot make the if condition for order.status term inside the Math execution script.

You don't need to use the group by here. You can create two series. The one that you want to be negative you could use the math aggregation as you've suggested. Then, in the options, under the filter, use something like order.status: cancelled. In the other series, use order.status: completed. Let me know if that works!

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