Count distinct number of combinations within groups
I have the following table as a data source in Power BI:
What I want to do is to see how many unique combinations of categories are there within all groups and sum them up by category. For example, category 3 has 4 total combinations across all groups (0 in group 1 + 2 in group 2 (with categories 1 and 2) + 2 in group 3 (with categories 1 and 2) = 4 combinations in total). In the end, I want a table that looks like this:
Have been testing various DAX functions in order to achieve that result, but no luck. Would greatly appreciate your help!