Forum Discussion
SUMX Distinct and GroupBy
- 7 years ago
Hi Anonymous ,
The correct result should be 10085. There could be two solutions. The basic idea is including the MonthNo and WeekNo at the same time.
Measure 2 = SUMX ( ALL ( DB[MonthNo], DB[WeekNo] ), CALCULATE ( MAX ( DB[Records] ) ) )
Measure 3 = SUMX ( SUMMARIZE ( DB, DB[MonthNo], DB[WeekNo], "maxRecords", MAX ( DB[Records] ) ), [maxRecords] )
Best Regards,
Hi Anonymous ,
Actually, this formula "RecordsMeasure = MAXX(DISTINCT(DB[Records]), MAX(DB[Records]))" equals the one below.
RecordsMeasure = MAX(DB[Records])
What are the values of DB[Records]? Can we calculate a Max value?
Generally, the results base on MonthNo or WeekNo are different. Do you mean you'd like to SUM them base on MonthNo and WeekNo?
Can you share a sample, please? Please mask the sensitive parts first.
Best Regards,
Thanks for your reply.
Yes I need to calculate the sum distinct by Monthno and weekno. Please see attached data set. Its basically MonthNo, WeekNo and actual values.
Please see link to data file on OneDrive with DB[Records] values
https://1drv.ms/x/s!AtGoFMN86r67ll-mnGmniDknC2zp
- v-jiascu-msft7 years ago
Microsoft Employee
Hi Anonymous ,
The correct result should be 10085. There could be two solutions. The basic idea is including the MonthNo and WeekNo at the same time.
Measure 2 = SUMX ( ALL ( DB[MonthNo], DB[WeekNo] ), CALCULATE ( MAX ( DB[Records] ) ) )
Measure 3 = SUMX ( SUMMARIZE ( DB, DB[MonthNo], DB[WeekNo], "maxRecords", MAX ( DB[Records] ) ), [maxRecords] )
Best Regards,
- Anonymous7 years agoNot applicable
Thanks v-jiascu-msft got the desired result now.