Here is a formula that appears to work, even when the rows are not sorted by the 2 levels. (i.e. sorted by date) The lagList in the formula, is there to handle the issue that the Col Moving Average() function returns the current row, even on the first occurrence.
If( Row() == 1, lagList = {} );
If( Contains( lagList, :administrative_area_level_1 || :administrative_area_level_2 ),
Col Moving Average(
:deaths,
weighting = 1,
before = 1,
:administrative_area_level_1,
:administrative_area_level_2
) * 2 - :deaths,
Insert Into( lagList, :administrative_area_level_1 || :administrative_area_level_2 )
);
Here is an inefficient formula that also works
curLevel1 = :administrative_area_level_1;
curLevel2 = :administrative_area_level_2;
curRow = Row();
Try(
:deaths[Max(
Current Data Table() << get rows where(
:administrative_area_level_1 == curLevel1 & (:administrative_area_level_2 == curLevel2 & Row() < curRow)
)
)]
);
Jim