Crossfilter works best with a flat arrays of records. If you don't like the idea of a reduce function creating maps, as suggested in the comments above, you can create a flat array out of your data basically by "multiplying out" the categories with the records.

So, something like this (using underscores's clone function to duplicate the records):

var product = [];
for(var r in records) {
    for(var i = 0; i < r.categories.length; ++i) {
        var r2 = _.clone(r);
        delete r2.categories;
        r2.category = r.categories[i];

(Warning: not tested.) Now, where you used to have n categories in a record, you'll have n records, one for each category. And you can reduce on category okay now.

... Of course it might make your other calculations messy or not work (some hints here), which is why I suggested the other answer first. Unfortunately crossfilter was not designed for dealing with multi-valued fields.

Related Query