The Values won't generally get affected by the Columns that we use for sorting
I tried your case with your data assuming that you are trying to find the Distinct Count of Value Column (in this case color) for your attributes (category, Type and Color) and the output screenshot is as below
I find the values to be appropriate (as expected).
Thanks for your replies. Your results are correct, but this does not match the case that I'm trying to solve here.
I am using SUMX() over Type because I want the Category to be the sum of distinct Colors within one Type at the time. So using my formula with SUMX() gives the following result:
Type A contains (blue, red) -> Sum for Type A = 2
Type B contains (red, yellow) -> Sum for Type B = 2
Cat1 contains (Type A, Type B) -> Sum for Cat1 = 2+2 = 4
Using CALCULATE() with VALUES(), or simply DISTINCTCOUNT() simply does not give the correct result. In that case, the total for Cat is 3 (blue, red, yellow), because, one of the colors is the same across Type. So it does not solve the issue actually...