Question wrt Lag working dynamically with period type


I have a Reporting Period control that changes date aggregation based on Week, Month, Quarter, Year. I’m trying to calculate the PoP percent difference based on the reporting period selected. Tried a lag function but it’s not quite giving me correct values for the previous spend. (See image). Can this be achieved? There are inbuilt periodOverPeriodDifference and PeriodOverPeriod percent difference but can they used with the date aggregation dynamically? Thanks a lot!

The formula for the field Lag_Test_Previous_Val is

[{Reporting_Period} ASC],1



I would look at this article!

It should have everything you are looking for!