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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply

Consecutive Fail for last 4 months _

Hi team

 

I want to highlight every month if prior to 3 months are consecutive failures.

 

I have attached the PBI File as sample. Please help. 

 

In Matrix view it should highlite when there are 3 consecvutive failures. Please please please help.

 

RatanBhushan_05_0-1688552379192.png

 

 

Thanks

3 ACCEPTED SOLUTIONS
v-jianboli-msft
Community Support
Community Support

Hi @RatanBhushan_05 ,

 

Please try:

Measure = 
var _a = COUNTX(FILTER(ALL('Table'),[KPI]=SELECTEDVALUE('Table'[KPI])&&[Date]>EOMONTH(SELECTEDVALUE('Table'[Date]),-1)&&[Date]<=EOMONTH(SELECTEDVALUE('Table'[Date]),3)&&[Value]="Fail"),[Value])
var _b = COUNTX(FILTER(ALL('Table'),[KPI]=SELECTEDVALUE('Table'[KPI])&&[Date]>EOMONTH(SELECTEDVALUE('Table'[Date]),-2)&&[Date]<=EOMONTH(SELECTEDVALUE('Table'[Date]),2)&&[Value]="Fail"),[Value])
var _c = COUNTX(FILTER(ALL('Table'),[KPI]=SELECTEDVALUE('Table'[KPI])&&[Date]>EOMONTH(SELECTEDVALUE('Table'[Date]),-3)&&[Date]<=EOMONTH(SELECTEDVALUE('Table'[Date]),1)&&[Value]="Fail"),[Value])
var _d = COUNTX(FILTER(ALL('Table'),[KPI]=SELECTEDVALUE('Table'[KPI])&&[Date]>EOMONTH(SELECTEDVALUE('Table'[Date]),-4)&&[Date]<=EOMONTH(SELECTEDVALUE('Table'[Date]),0)&&[Value]="Fail"),[Value])
return IF(_a=4||_b=4||_c=4||_d=4,"Green","White")

Final output:

vjianbolimsft_1-1688709711267.png

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @RatanBhushan_05 ,

 

Its calculation logic is this:

imagine four consecutive months as four fixed positions, consider the current month in the four positions respectively, that is, the variables a, b,c,d as long as one of these four variables meets the requirements, then it means that it is in the four consecutive months.

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @RatanBhushan_05 ,

 

Please try:

Measure =
VAR _a =
    COUNTX (
        FILTER (
            ALL ( 'Table' ),
            [KPI] = SELECTEDVALUE ( 'Table'[KPI] )
                && [Date] > EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), -1 )
                && [Date] <= EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), 3 )
                && YEAR ( [Date] ) = YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
                && [Value] = "Fail"
        ),
        [Value]
    )
VAR _b =
    COUNTX (
        FILTER (
            ALL ( 'Table' ),
            [KPI] = SELECTEDVALUE ( 'Table'[KPI] )
                && [Date] > EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), -2 )
                && [Date] <= EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), 2 )
                && YEAR ( [Date] ) = YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
                && [Value] = "Fail"
        ),
        [Value]
    )
VAR _c =
    COUNTX (
        FILTER (
            ALL ( 'Table' ),
            [KPI] = SELECTEDVALUE ( 'Table'[KPI] )
                && [Date] > EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), -3 )
                && [Date] <= EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), 1 )
                && YEAR ( [Date] ) = YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
                && [Value] = "Fail"
        ),
        [Value]
    )
VAR _d =
    COUNTX (
        FILTER (
            ALL ( 'Table' ),
            [KPI] = SELECTEDVALUE ( 'Table'[KPI] )
                && [Date] > EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), -4 )
                && [Date] <= EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), 0 )
                && YEAR ( [Date] ) = YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
                && [Value] = "Fail"
        ),
        [Value]
    )
RETURN
    IF ( _a = 4 || _b = 4 || _c = 4 || _d = 4, "Green", "White" )

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9

This is just perfect - Thank you so much - 
Could you please little try to debried what is happening here - please.

Hi @RatanBhushan_05 ,

 

Its calculation logic is this:

imagine four consecutive months as four fixed positions, consider the current month in the four positions respectively, that is, the variables a, b,c,d as long as one of these four variables meets the requirements, then it means that it is in the four consecutive months.

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Just to make another scenario - if year changes and we have to count 4 months again from next year Jan - could you please try for that also.? It will be a big favour.

Hi @RatanBhushan_05 ,

 

Please try:

Measure =
VAR _a =
    COUNTX (
        FILTER (
            ALL ( 'Table' ),
            [KPI] = SELECTEDVALUE ( 'Table'[KPI] )
                && [Date] > EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), -1 )
                && [Date] <= EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), 3 )
                && YEAR ( [Date] ) = YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
                && [Value] = "Fail"
        ),
        [Value]
    )
VAR _b =
    COUNTX (
        FILTER (
            ALL ( 'Table' ),
            [KPI] = SELECTEDVALUE ( 'Table'[KPI] )
                && [Date] > EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), -2 )
                && [Date] <= EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), 2 )
                && YEAR ( [Date] ) = YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
                && [Value] = "Fail"
        ),
        [Value]
    )
VAR _c =
    COUNTX (
        FILTER (
            ALL ( 'Table' ),
            [KPI] = SELECTEDVALUE ( 'Table'[KPI] )
                && [Date] > EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), -3 )
                && [Date] <= EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), 1 )
                && YEAR ( [Date] ) = YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
                && [Value] = "Fail"
        ),
        [Value]
    )
VAR _d =
    COUNTX (
        FILTER (
            ALL ( 'Table' ),
            [KPI] = SELECTEDVALUE ( 'Table'[KPI] )
                && [Date] > EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), -4 )
                && [Date] <= EOMONTH ( SELECTEDVALUE ( 'Table'[Date] ), 0 )
                && YEAR ( [Date] ) = YEAR ( SELECTEDVALUE ( 'Table'[Date] ) )
                && [Value] = "Fail"
        ),
        [Value]
    )
RETURN
    IF ( _a = 4 || _b = 4 || _c = 4 || _d = 4, "Green", "White" )

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Jianbo

 

Could you please look into one more thing which I have been trying - 
If I want to see in the same table the running total - but the catch is if any month is blank then running total will start from one again -

 

 

 

RatanBhushan_05_1-1690274936851.png

As you can see in the attached pic - i have been trying but insted of starting from 1 it is starting from same previous running total 

Please help me in this.. Please..

You are a gem of a person. 
Love from India

v-jianboli-msft
Community Support
Community Support

Hi @RatanBhushan_05 ,

 

Please try:

Measure = 
var _a = COUNTX(FILTER(ALL('Table'),[KPI]=SELECTEDVALUE('Table'[KPI])&&[Date]>EOMONTH(SELECTEDVALUE('Table'[Date]),-1)&&[Date]<=EOMONTH(SELECTEDVALUE('Table'[Date]),3)&&[Value]="Fail"),[Value])
var _b = COUNTX(FILTER(ALL('Table'),[KPI]=SELECTEDVALUE('Table'[KPI])&&[Date]>EOMONTH(SELECTEDVALUE('Table'[Date]),-2)&&[Date]<=EOMONTH(SELECTEDVALUE('Table'[Date]),2)&&[Value]="Fail"),[Value])
var _c = COUNTX(FILTER(ALL('Table'),[KPI]=SELECTEDVALUE('Table'[KPI])&&[Date]>EOMONTH(SELECTEDVALUE('Table'[Date]),-3)&&[Date]<=EOMONTH(SELECTEDVALUE('Table'[Date]),1)&&[Value]="Fail"),[Value])
var _d = COUNTX(FILTER(ALL('Table'),[KPI]=SELECTEDVALUE('Table'[KPI])&&[Date]>EOMONTH(SELECTEDVALUE('Table'[Date]),-4)&&[Date]<=EOMONTH(SELECTEDVALUE('Table'[Date]),0)&&[Value]="Fail"),[Value])
return IF(_a=4||_b=4||_c=4||_d=4,"Green","White")

Final output:

vjianbolimsft_1-1688709711267.png

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.