A possible solution is to build a table of the Years and Months since the first Year in the table and remove from it the Year Months that appear in the table. Than compute the difference in months between the current Year Month and the last non existent Year Month.
This is a possible calculated column that uses the EXCEPT function to build the table with the missing Year Months. To ease the computation of the difference in months across the years, it also prepares a YearMonthNumber value with the progressive month number from the first year month
Since in the example table there are separate columns for the Status, I added an IF to split the columns accordingly
I also added a check to return 0 instead of 1, to match the example data
Consecutive Months Missing =
IF (
T[Status] = "Missing",
VAR FirstYear =
MIN ( T[Year] )
VAR CurrentYear = T[Year]
VAR CurrentMonth = T[Month]
VAR CurrentYearMonthNumber = ( CurrentYear - FirstYear ) * 12 + CurrentMonth
VAR YearMonths =
GENERATE (
SELECTCOLUMNS ( GENERATESERIES ( FirstYear, CurrentYear ), "Year", [Value] ),
SELECTCOLUMNS (
GENERATESERIES ( 1, 12, 1 ),
"Month", [Value],
"YearMonthNumber",
( [Year] - FirstYear ) * 12 + [Value]
)
)
VAR CurrentIDAndStatusYearMonths =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( T, T[Year], T[Month] ),
"YearMonthNumber",
( T[Year] - FirstYear ) * 12 + T[Month]
),
ALLEXCEPT ( T, T[ID], T[Status] )
)
VAR MissingYearMonths =
EXCEPT ( YearMonths, CurrentIDAndStatusYearMonths )
VAR FirstMissingYearMonthNumber =
MAXX (
FILTER ( MissingYearMonths, [YearMonthNumber] < CurrentYearMonthNumber ),
[YearMonthNumber]
)
VAR Result = CurrentYearMonthNumber - FirstMissingYearMonthNumber
RETURN
IF ( Result = 1, 0, Result )
)
and
Consecutive Months On Hold =
IF (
T[Status] = "On Hold",
VAR FirstYear =
MIN ( T[Year] )
VAR CurrentYear = T[Year]
VAR CurrentMonth = T[Month]
VAR CurrentYearMonthNumber = ( CurrentYear - FirstYear ) * 12 + CurrentMonth
VAR YearMonths =
GENERATE (
SELECTCOLUMNS ( GENERATESERIES ( FirstYear, CurrentYear ), "Year", [Value] ),
SELECTCOLUMNS (
GENERATESERIES ( 1, 12, 1 ),
"Month", [Value],
"YearMonthNumber",
( [Year] - FirstYear ) * 12 + [Value]
)
)
VAR CurrentIDAndStatusYearMonths =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( T, T[Year], T[Month] ),
"YearMonthNumber",
( T[Year] - FirstYear ) * 12 + T[Month]
),
ALLEXCEPT ( T, T[ID], T[Status] )
)
VAR MissingYearMonths =
EXCEPT ( YearMonths, CurrentIDAndStatusYearMonths )
VAR FirstMissingYearMonthNumber =
MAXX (
FILTER ( MissingYearMonths, [YearMonthNumber] < CurrentYearMonthNumber ),
[YearMonthNumber]
)
VAR Result = CurrentYearMonthNumber - FirstMissingYearMonthNumber
RETURN
IF ( Result = 1, 0, Result )
)
this is the resulting table put in a table visual