Kibana Scripted Field count

Hi,

I am new to kibana. Is there a way to create a scripted field with count.

For example:
I have a table with persons and there is the column "gender". I want a scripted field where I can select how often "male" is in the table?

The return should just be the number how often the table contains "male"?

Thank you in advance!

AFAIK
Scripted fields work on the document level. So you cannot aggregate.
But what is the use case?
If you want to count, just create a numerical visualisation.

Just your data table visualization should be enough to give the count of males.
Scripted field is not needed for the above