I have a table visual, no matter how i try get a total of only the negative numbers summed up it still calculates completely wrong. For example the total should be -79000, and I am getting -3278
My DAX
TotalCalculatedValue2 =
SUMX(
MeterTable,
SWITCH(
TRUE(),
MeterTable[Meter] = “Colour”, [Diff XSM-XERM] * 0.05,
MeterTable[Meter] = “Mono”, [Diff XSM-XERM] * 0.005,
0 – Default value if neither Colour nor Mono
)
)
Thanks you will find in most cases, there is no way we can send PBIX files especially from firms, as its seen as a major security issue, thanks anyway.
This measure calculates CalculatedValue once per row using SWITCH and then filters out non-negative results with the IF statement. This should yield the correct total by summing only negative values, but if this still doesn’t produce the expected result, please share a minimal .pbix example with some sample data.
The issue you’re seeing is rooted in how DAX handles filter context at the total level.
Your original measure calculates the maximum value for each serial number over the last three months, but in the total row, DAX removes the row context for each serial number and finds the overall maximum across the entire dataset instead. This is why the total doesn’t match the sum of individual max values.
If you want the total row to reflect the sum of each serial number’s maximum over the last three months, you can replace your Max_Last_3_MonthsXSM measure with:
SUMMARIZE creates a vtable that groups by Serial and calculates each serial number’s maximum value over the last three months, CALCULATE with DATESINPERIOD filters the data to the last three months for each serial number, then finds the maximum XSValue within that period. Finally, SUMX iterates over the virtual table, summing the MaxValue for each serial number. This ensures that the total row represents the sum of individual max values rather than a single maximum for the entire dataset.
You can apply a similar pattern to other measures where you want the total row to aggregate individual row calculations rather than recalculating across the whole dataset.
Yes i get to this point and no further. need the sum of the column max.
I get the max of the XSM value for the last 3 months, if there is the same value for two of the months i only want one(which we get), just to sum up those single values within that column.