Display difference of two values of query result

As you can see in the picture below, I have a result set which consists of three sums grouped by the even_type.keyword.

What I am trying to achieve is to display the difference between the ShipmentDeclarationSent sum and the CancelOrderSent sum (which should be 0 at that point) using the stat visualization panel like below.

How can I achieve this? Any advice is greatly appreciated.

Hi @theresalichtenberger ,

It looks like you’ve added a transformation. Can you share a screenshot of that as well?

sure, please have a look:

Is this what you’re trying to achieve? I copied your data into a static table and then applied your transformation. Selecting Show --> Cacluation and Calculation --> Total calculates the “difference”:

https://play.grafana.org/d/p-aTRUqMk/transformation-test-copy?orgId=1&editPanel=2

I would note that selecting difference will give you the length of the span from that negative to positive integer. Will CancelOrderSent always return 0 or a negative number?

1 Like

hey, thanks again for your answer. I tried to look up your example. But I cannot inspect your transformation. With my transformation above, I just wanted to remove the ZapaShipmentDelcarationSent value from my query so I can calculate the difference (ShipmentDeclarationSent - CancelOrderSent). Could you please tell me how the tranformation must look like in order to achieve this?

I did the same inside the Transform panel. Weird that it won’t open.

The second transformation takes place here, inside the Stat panel:

1 Like