Forum Discussion
Summing value from a matrix
- 1 year ago
Hi Anonymous , Thank you for reaching out to the Microsoft Community Forum.
Build a new measure that recreates that row-level context manually using SUMMARIZE, and then sums the results with SUMX. Example:
TotalReallocateClasses =
VAR vTable =
SUMMARIZE(
Sheet1,
Sheet1[acad_org],
Sheet1[day_of_week],
"__Reallocation", [ReallocateClassesPerDay]
)
RETURN
SUMX(vTable, [__Reallocation])This forces DAX to recalculate [ReallocateClassesPerDay] for every (acad_org, day_of_week) pair exactly as it appears in the matrix and then adds them up to give the true total. After writing this measure, drop it into a card visual to display the correct total number of classes that need to be reallocated.
If this helped solve the issue, please consider marking it “Accept as Solution” so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.
It is likely that the context supplied by your matrix visual is not being supplied to the card visual. Specifically, the day of week and acad_org context would not exist in a card so the VAR TotalClassess and VAR ClassesOnThisDay portion of your measure are not going to be calculated "correctly". You may be able to to fix this by creating a measure that creates a virtual table that summarizes by day and acad_org and then uses your measure as the value. You could then sumx over the table to get your total.
In pseudo code it would look something like...
Measure =
var _vTable =
SUMMARIZE(
'Table',
'Table'[acad_org],
'Table'[DayOfWeek],
"__value", [YourMeasureName]
)
RETURN
SUMX(
_vTable,
[__value]
)
Hope this gets you pointed in the right direction.