Forum Discussion
etane
Helper V
1 year agoIncorrect Matrix Total when using MAXX Measure
Hello. I have a dataset where I am using a measure to calculate the latest inputed forecast by Rep, Product and Calendar Year/Month via a MAXX function a key date column. The calculation is cor...
- 1 year ago
Hi etane
Could you please follow below steps:- Create a basic total (for reference)
Sum of Amount = SUM ( Data[Amount] )2.Naïve “latest forecast” (shows the total bug)
- Fix: make the Total sum rows
- Use ISINSCOPE to detect when you’re on a row vs. the total; at the total, sum each Rep’s row value.
Forecast Selected (naive) = VAR vLastDate = CALCULATE ( MAX ( Data[Date] ), REMOVEFILTERS ( Data[Date] ) ) RETURN CALCULATE ( SUM ( Data[Amount] ), Data[Date] = vLastDate )- This works per Rep row.
- At the Total, there’s no Rep in scope; it finds the overall max date (in the sample it’s 2025-04-01) and returns that single month’s amount (= 60,000).
Forecast Selected = IF ( ISINSCOPE ( Data[Rep] ), [Forecast Selected (naive)], SUMX ( VALUES ( Data[Rep] ), [Forecast Selected (naive)] ) )3.Build the matrix
- Rows: Data[Rep]
- Values: Sum of Amount, Forecast Selected
rohit1991
Super User
1 year agoHi etane
Could you please follow below steps:
- Create a basic total (for reference)
Sum of Amount = SUM ( Data[Amount] )
2.Naïve “latest forecast” (shows the total bug)
- Fix: make the Total sum rows
- Use ISINSCOPE to detect when you’re on a row vs. the total; at the total, sum each Rep’s row value.
Forecast Selected (naive) =
VAR vLastDate =
CALCULATE ( MAX ( Data[Date] ), REMOVEFILTERS ( Data[Date] ) )
RETURN
CALCULATE ( SUM ( Data[Amount] ), Data[Date] = vLastDate )
- This works per Rep row.
- At the Total, there’s no Rep in scope; it finds the overall max date (in the sample it’s 2025-04-01) and returns that single month’s amount (= 60,000).
Forecast Selected =
IF (
ISINSCOPE ( Data[Rep] ),
[Forecast Selected (naive)],
SUMX ( VALUES ( Data[Rep] ), [Forecast Selected (naive)] )
)
3.Build the matrix
- Rows: Data[Rep]
- Values: Sum of Amount, Forecast Selected
- etane1 year ago
Helper V
Thanks!
- etane1 year ago
Helper V
rohy . So, when one product is selected, the measure works because there's one max date per rep. However, when the product is not selected, the measure doesn't work because the max date only works on the product that has the latest date.
Could you please modify the measure so there's a max date not only by rep but also by product?