Forum Discussion
victorlopes1998
3 years agoNew Member
Sumx() returning wrong total
Hello all!
I'm trying to monthly my weight by distinct count of dates doing:
MONTHLY WEIGHT = SUMX(Plan1,
DIVIDE(Plan1[WEIGHT],DISTINCTCOUNT(Plan1[DATE])))
And I need to get the sum of results line by line to show as a card
But I'm getting the wrong result:
The correct result is 173+113 = 286 instead of 221.
Try this measure:
MONTHLY WEIGHT = VAR vTable = ADDCOLUMNS ( SUMMARIZE ( Plan1, Plan1[DESTINY], Plan1[ORIGIN] ), "@Weight", CALCULATE ( SUM ( Plan1[WEIGHT] ) ), "@CountDistinctDate", CALCULATE ( DISTINCTCOUNT ( Plan1[DATE] ) ) ) VAR vResult = SUMX ( vTable, DIVIDE ( [@Weight], [@CountDistinctDate] ) ) RETURN vResult
2 Replies
- DataInsightsSuper User
Try this measure:
MONTHLY WEIGHT = VAR vTable = ADDCOLUMNS ( SUMMARIZE ( Plan1, Plan1[DESTINY], Plan1[ORIGIN] ), "@Weight", CALCULATE ( SUM ( Plan1[WEIGHT] ) ), "@CountDistinctDate", CALCULATE ( DISTINCTCOUNT ( Plan1[DATE] ) ) ) VAR vResult = SUMX ( vTable, DIVIDE ( [@Weight], [@CountDistinctDate] ) ) RETURN vResult- victorlopes1998New Member
Thank you!!! It works fine and solve my problem!!