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.
You're encountering a common issue in DAX where the total of a measure in a matrix does not match the sum of the visible values, especially when using ALLEXCEPT, SELECTEDVALUE, and SWITCH logic. The root of the issue is that DAX recomputes the measure at the total level with different filter context, which leads to different logic paths being executed.
To properly aggregate your measure, we must recompute it row by row over the same grain as your matrix (acad_org × day) and then sum the results.
Here’s the pattern:
TotalReallocateClasses =
SUMX(
SUMMARIZE(
Sheet1,
Sheet1[acad_org],
Sheet1[day_of_week], -- Adjust if this is not the exact column name
"Realloc", [ReallocateClassesPerDay]
),
[Realloc]
)