Metric count aggregation difference

I have a index with source field. It can have two values. For ex: "sourceA" & "sourceB".
I am trying to create to metric aggregation panels with source filter.
It is possible to create metric aggregation with single filter source : "source A" or "source B" and get the respective count of documents.

However
I want to create a metric aggregation visualization with difference in the count of documents with souce A and source B.
Could you please help?

Hi @gijo ,

welcome to the Kibana community.

I want to create a metric aggregation visualization with difference in the count of documents with souce A and source B.

If I understood correctly your request, I think Lens new formula feature can be useful.

If sourceA and sourceB are mutually exclusive probably you can do something like:

count(kql='sourceA: *') - count(kql='sourceB: *')

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