Forum Discussion
Wrong total sum, distinct count
- 6 years ago
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.
- 6 years ago
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.
Anonymous try this measure
Sum of distinct count =
SUMX ( VALUES ( Table[Brand] ), [Z_DistCount] )
Thank you, parry2k, but gives me not the correct result.
- Greg_Deckler6 years ago
Community 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.
- Anonymous6 years agoNot applicable
Greg_Deckler: This is very neat, too. Thank you, Greg. So the part where you state
COUNTX(DISTINCT(SUMMARIZE(caters for older version of Power BI, am I right? The younger formula
DISTINCTCOUNT()makes it shorter than before, correct?
- Greg_Deckler6 years ago
Community Champion
Unless it has changed recently, DISTINCTCOUNT only accepts an actual column in an actual table as a parameter. Thus, if we are working with a table expression, we cannot use DISTINCTCOUNT and have to essentially code around it in the manner shown. There is no DISTINCTCOUNTX function like there is COUNTX so we have to work around that.