Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
RichA08
Frequent Visitor

Matrix to Only Show Negative Values for Consecutive Months

Hi All, 

 

I'm looking to create a matrix visual that only shows the items that have a negative or 0 for the last 3 consecutive months. Filtering seems to only apply to part of the data. So it might only filter for the first month, but not the months after that. How would I acheive for it to only show if each of the past 3 months have been negative or zero? 

 

Sample Dataset. 

IDMonth Accuracy
1Jan-30
1Feb-1
1March7
2Jan-20
2Feb-30
2March-45
3Jan23
3Feb-20
3March14
4Jan-11
4Feb-20
4March-30
5Jan4
5Feb6
5March-30
1 ACCEPTED SOLUTION
KNP
Super User
Super User

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.

 

KNP_0-1760383279986.png

 

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.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

View solution in original post

2 REPLIES 2
KNP
Super User
Super User

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.

 

KNP_0-1760383279986.png

 

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.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!
RichA08
Frequent Visitor

Thank you!! Worked beautifully 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors