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
vanrensburga
Regular Visitor

Count consecutive values across columns where a value > x

Good day

I am relatively new to PowerBI, and I have the following table with #High % (>=65%) calculated correctly.  I want to count the consecutive years across the columns where the % is >= 65%, and the output should be as per below (Column Name # Consecutive years%.  However, the output I get is shown in bold, which is incorrect.  For the # consecutive, I created a Consecutive Years Temp with the following dax (see below the table) and then another measure for #consecutive years%.  What am I doing wrong?

Yr 1Yr 2Yr 3Yr 4Yr 5# High % (5Yrs)# Consecutive years %
13436%40%721%4%17%21 2
2406%64%99%5%376%31 4
166%64%74%17%349%31 2
135%151%6%45%13%22 2
71%112%27%113%70%42

 

--1st Measure
ConsecutiveYearsTemp =
IF (
    'CPR'[YR1%] > 0.65
        || 'CPR'[YR2%] > 0.65
        || 'CPR'[YR3%] > 0.65
        || 'CPR'YR4%] > 0.65
        || 'CPR'[YR5%] > 0.65,
    1,
    0
)
--2nd Measure
ConsecutiveYears =
CALCULATE (
    MAXX (
        FILTER (
            ALL ( 'CPR' ),
            'CPR'[CurrentPeriodExpiryDate] <= 'CPR'[CurrentPeriodExpiryDate]
                && 'CPR'[YR1%] > 0.65
        ),
        'CPR'[ConsecutiveYearsTemp] + 1
    ),
    'CPR'[ConsecutiveYearsTemp] + 1
)


Cheers
 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@vanrensburga , This should be end

IF (
'CPR'[YR1%] > 0.65
&& 'CPR'[YR2%] > 0.65
&& 'CPR'[YR3%] > 0.65,
1,
0
)

Also, you can try measures like
if( CALCULATE(Countx(filter(Values('Date'[Year]), [%] >.65), [Year]) , WINDOW(-2,REL, 0, REL, ALLSELECTED('Date'[Year]),ORDERBY([Year],Desc))) >=3,1,0)

Continue to explore Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
https://medium.com/@amitchandak/power-bi-window-function-3d98a5b0e07f


Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@vanrensburga , This should be end

IF (
'CPR'[YR1%] > 0.65
&& 'CPR'[YR2%] > 0.65
&& 'CPR'[YR3%] > 0.65,
1,
0
)

Also, you can try measures like
if( CALCULATE(Countx(filter(Values('Date'[Year]), [%] >.65), [Year]) , WINDOW(-2,REL, 0, REL, ALLSELECTED('Date'[Year]),ORDERBY([Year],Desc))) >=3,1,0)

Continue to explore Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
https://medium.com/@amitchandak/power-bi-window-function-3d98a5b0e07f


Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you very much.  

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
Top Kudoed Authors