Calculating count per term filter within one metric

Ah, yeah if you need to make calculations like this which are based on other computed metrics/buckets, then what you are probably looking for is a bucket script aggregation or a scripted metric aggregation. Unfortunately these aren't currently supported in Kibana, but there are Github issues tracking support here and here.

In the meantime, Timelion with Canvas is probably the best workaround I can think of for achieving a similar result