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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ssk_1984
Helper II
Helper II

Consecutive Row Count from date between Current Month and follow up 2 month

Hi Team,

 

Pleaes help me to create measure to get the below results

 

VerticalREPORT_DATESLA_MISSESCurrent Month & Follow Two Months same value
BFS01-01-2022Met 
BFS01-02-2022Not Met1
BFS01-03-2022Not Met 
BFS01-04-2022Not Met 
CMT01-01-2022Not Met1
CMT01-02-2022Not Met1
CMT01-03-2022Not Met 
CMT01-04-2022Not Met 
Digi. Fin.01-01-2022Met 
Digi. Fin.01-02-2022Met 
Digi. Fin.01-03-2022Met 
HC01-01-2022Met 
HC01-02-2022Met 
HC01-03-2022Met 
INS01-01-2022Met 
INS01-02-2022Met 
INS01-03-2022Met 
LS01-01-2022Met 
LS01-02-2022Met 
LS01-03-2022Met 
RHCG01-03-2022Met 

 

from the above table of info, I want to count as one, when Current Month and followed by two Months is 'Not Met', Then current month counted as one. else no action.

 

Here Ref vertical 'CMT' from Jan to Apr, we have all 'not met' only, Considering Jan it should give me a value 1, Because Jan, feb & Mar has same value.

For feb Also 1, Current month Feb is not met and the consecutive 2 months not met, Mar & Apr...then Feb count as 1.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @ssk_1984 
Please refer to attached sample file with the solution

1.png

Current Month & Follow Two Months same value = 
VAR CurrentDate = 'Table'[REPORT_DATE]
VAR CurrentVerticalTable = CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Vertical] ), 'Table'[REPORT_DATE] >= CurrentDate )
VAR T1 = ADDCOLUMNS ( CurrentVerticalTable, "@Rank1", RANKX ( CurrentVerticalTable, [REPORT_DATE],, ASC, Dense ) )
VAR T2 = FILTER ( T1, 'Table'[SLA_MISSES] = "Not Met" )
VAR T3 = ADDCOLUMNS ( T2, "@Rank2", RANKX ( T2, [REPORT_DATE],, ASC, Dense ) )
VAR T4 = FILTER ( T3, [@Rank1] = [@Rank2] )
VAR Result = IF ( COUNTROWS ( T4 ) >= 3, 1 )
RETURN
    Result

View solution in original post

3 REPLIES 3
ssk_1984
Helper II
Helper II

I have wrongly given the dataset, I working fine...Gr8...Thank you very much

 

tamerj1
Super User
Super User

Hi @ssk_1984 
Please refer to attached sample file with the solution

1.png

Current Month & Follow Two Months same value = 
VAR CurrentDate = 'Table'[REPORT_DATE]
VAR CurrentVerticalTable = CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Vertical] ), 'Table'[REPORT_DATE] >= CurrentDate )
VAR T1 = ADDCOLUMNS ( CurrentVerticalTable, "@Rank1", RANKX ( CurrentVerticalTable, [REPORT_DATE],, ASC, Dense ) )
VAR T2 = FILTER ( T1, 'Table'[SLA_MISSES] = "Not Met" )
VAR T3 = ADDCOLUMNS ( T2, "@Rank2", RANKX ( T2, [REPORT_DATE],, ASC, Dense ) )
VAR T4 = FILTER ( T3, [@Rank1] = [@Rank2] )
VAR Result = IF ( COUNTROWS ( T4 ) >= 3, 1 )
RETURN
    Result

Thank you for your time, 

 

ssk_1984_0-1671015683883.png

In this first one coming as wrong, for Dec...i dont have consecutive not met for Jan & Feb..But appearing as one count

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.