MyFilteredCumulativeMeasure =
COUNTROWS(
FILTER(
GENERATE(
ALL( 'MyTable'[name] )
,CALCULATETABLE(
SAMPLE(
1
,SUMMARIZE(
'MyTable'
,'MyTable'[month]
,'MyTable'[flag]
)
,'MyTable'[month]
,DESC
)
,FILTER(
ALL( 'MyTable'[month] )
,'MyTable'[month] <= MAX( 'MyTable'[month] )
)
)
)
,'MyTable'[flag]
)
)
This works on your sample. Might need some tweaking for the real data. Also likely to slow down significantly as data size increases. I'll continue noodling on it, because this doesn't feel quite right, but it's a good naive implementation.