I’m not sure I completely understood the problem, but to me you just need a standard AVERAGE and not the AVERAGEX iterator.
I’ve changed the formula a bit and didn’t use DATESINPERIOD, this one achieves the same result and (to me) is more clear and readable
Avg = VAR DaysInterval = 28 RETURN CALCULATE ( AVERAGE ( myTable[Value] ), DATESBETWEEN ( myTable[Date], MAX ( myTable[Date] ) - DaysInterval, --from MAX ( myTable[Date] ) + DaysInterval --to ) )
here is the result (based on the sample dataset)
CLICK HERE to find out more related problems solutions.