Need help with aggregation: groups & subgroups

Hi! I hope it’s ok to ask for help with something. I have an aggregation pipeline that groups survey answers by the contents of field A, and I would like to now also group it by field B.

In other words for answer B1 have e.g. three groups for answers A1, A2, A3, then for answer B2 have three groups for A1, A2, A3, and so on. For example, using gender and age:

[
  {
    gender: 'woman'
    data: [
      { age: '0-10', count: 123 },
      { age: '10-20', count: 567 },
      ...
    ]
  },
 {
    gender: 'non_binary'
    data: [
      { age: '0-10', count: 456 },
      { age: '10-20', count: 789 },
      ...
    ]
  },
...
]

More details are available here: Mongo Aggregation Help: Facets Breakdown · Issue #192 · Devographics/state-of-js-graphql-results-api · GitHub

Any help will be much appreciated!