Forum Discussion
Matrix to Only Show Negative Values for Consecutive Months
- 10 months ago
Hi RichA08,
So, not sure exactly what your complete model looks like, so a couple of things first.
I added a Date column to the sample data and called it 'Date'.
Date = DATEVALUE("2025" & " " & 'Table'[Month ] & " 1")I then created a measure...
ID Last 3 Months Non Positive = VAR __latestDate = CALCULATE( MAX('Table'[Date]) , ALLEXCEPT('Table', 'Table'[ID]) ) VAR __windowCount = CALCULATE( COUNTROWS('Table') , ALLEXCEPT('Table', 'Table'[ID]) , DATESINPERIOD( 'Table'[Date] , __latestDate , -2 , MONTH ) ) VAR __windowMax = CALCULATE( MAX('Table'[Accuracy]) , ALLEXCEPT('Table', 'Table'[ID]) , DATESINPERIOD( 'Table'[Date] , __latestDate , -2 , MONTH ) ) VAR __result = IF( __windowCount > 0 && __windowMax <= 0 , 1 , 0 ) RETURN __resultAdd this measure to the filter pane where the value is 1.
This should give you what you're looking for.
My code is often GitHub Copilot assisted, but unlike many others, tested to confirm results are correct.
Hi RichA08,
So, not sure exactly what your complete model looks like, so a couple of things first.
I added a Date column to the sample data and called it 'Date'.
Date = DATEVALUE("2025" & " " & 'Table'[Month ] & " 1")
I then created a measure...
ID Last 3 Months Non Positive =
VAR __latestDate =
CALCULATE(
MAX('Table'[Date])
, ALLEXCEPT('Table', 'Table'[ID])
)
VAR __windowCount =
CALCULATE(
COUNTROWS('Table')
, ALLEXCEPT('Table', 'Table'[ID])
, DATESINPERIOD(
'Table'[Date]
, __latestDate
, -2
, MONTH
)
)
VAR __windowMax =
CALCULATE(
MAX('Table'[Accuracy])
, ALLEXCEPT('Table', 'Table'[ID])
, DATESINPERIOD(
'Table'[Date]
, __latestDate
, -2
, MONTH
)
)
VAR __result =
IF(
__windowCount > 0
&& __windowMax <= 0
, 1
, 0
)
RETURN __result
Add this measure to the filter pane where the value is 1.
This should give you what you're looking for.
My code is often GitHub Copilot assisted, but unlike many others, tested to confirm results are correct.
Thank you!! Worked beautifully