Forum Discussion
Wrong total sum, distinct count
I have this table:
I want to show only those brands with more than 2 distinct articles.
This measure works fine for all the numbers in the table, but total sum fails.
I was not able to adapt for Greg's solution.
Is there a DAX formula to do so?
I believe you want something like this, should have the right total:
Measure 2 = VAR __Sales = SUMMARIZE(articles,[Brand],"__Sales",SUM([Sales]),"__Count",COUNTX(DISTINCT(SUMMARIZE(articles,[Articles])),[Articles])) RETURN SUMX(FILTER(__Sales,[__Count]>2),[__Sales])See attached, Page 2, articles table.
Hi,
Try these measures
Total sales = SUM(Data[Sales])Number of articles = DISTINCTCOUNT(Data[Articles])Measure = SUMX(FILTER(SUMMARIZE(VALUES(Data[Brand]),Data[Brand],"ABCD",[Number of articles],"EFGH",[Total sales]),[ABCD]>2),[EFGH])Hope this helps.
12 Replies
- parry2kSuper User
Anonymous try this measure
Sum of distinct count = SUMX ( VALUES ( Table[Brand] ), [Z_DistCount] )- AnonymousNot applicable
Thank you, parry2k, but gives me not the correct result.
- Greg_DecklerCommunity Champion
I believe you want something like this, should have the right total:
Measure 2 = VAR __Sales = SUMMARIZE(articles,[Brand],"__Sales",SUM([Sales]),"__Count",COUNTX(DISTINCT(SUMMARIZE(articles,[Articles])),[Articles])) RETURN SUMX(FILTER(__Sales,[__Count]>2),[__Sales])See attached, Page 2, articles table.
- Greg_DecklerCommunity ChampionCan you post that raw data as text and can you also post your expected result of your sample data?
- AnonymousNot applicable
Brand;Articles;Sales
A;Article1;4
A;Article2;2
A;Article1;2
A;Article1;5
B;Article3;10
B;Article3;105
B;Article3;26
C;Article1;24
C;Article2;27
C;Article3;85
C;Article4;63
D;Article5;15
D;Article5;45
E;Article5;65
E;Article2;35
E;Article2;85
E;Article2;91
E;Article1;10- AnonymousNot applicable
Should be the result