Skip to content
Advertisement

How to sum up unique values using case statements having certain conditions

I have a table that may have the same item but with different sizes, I would like to count those items with more than one size (e.g. marvel shirt with S, M sizes will count as “1”), but still be able to count how many S and M. I have 2 outcomes I would like to get. Please see below for more detail.

I tried just counting it but it is incorrect since it counts how many distinct sizes are there

Actual outcome (incorrect):

Desired/expected outcome:

Below is another possible desired outcome given this scenario: What if those with multiple sizes shouldn’t be counted separately (i.e. Marvel shirt has multiple sizes, thus it won’t count the S or M since it’s already counted under Multiple_Sizes)?

Advertisement

Answer

You probably need to group twice (1) by item number (2) by item category:

And the variation:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement