I have two main 'groups' of categories. I would like to have a table on a certain page that contains counts for the number of posts with combinations of categories from these two groups. So for instance, if my first groups contains categories 'A', 'B', 'C' and my second group contains categories 'X', 'Y', 'Z', I'd like to have a table like
| X | Y | Z |
A | count(AX) | count(AY) | count(AZ) |
B | count(BX) | count(BY) | count(BZ) |
C | count(CX) | count(CY) | count(CZ) |
with count(AX) meaning the number of posts that have both category A and category X.
How would I best go about this?