Introduce count_by with a secondary field

I've re-used "count_by" the expression because there isn't ambiguity, but happy to give it a different name too if people prefer.