Split columns in a table

Not sure if this will work for your use case:

First, split rows using a terms aggregation on your string field. Then, split table (columns) using a terms aggregation on your integer field.

The metric will be count.