Count of true values in Kibana data table

I'm doing a Kibana data table which looks like:

Environment Field1 Field2 Field3 Field4
Dev Sum Sum Sum ???
QA Sum Sum Sum ???
Stage Sum Sum Sum ???
Prod Sum Sum Sum ???

Field1, Field2, and Field3 are numeric fields, and I want the sum of those - no problem. However, Field4 is a Boolean field. What I need is to have Field4 be the number of true values in the field.

In SQL, I would do:

select
    sum(case 1 when 't.Field4' else 0 end) as Field4
from table t

I assume there's a way to do the same in a Kibana data table, probably using advanced field configuration and either sum or count, but I'm not certain where to start.

That can be handled by adding a scripted field called Field4_SF as follow then use it with sum in your data table

if( !doc['t.Field4'].empty && doc['t.Field4']) {
    return 1;
} else return 0;

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