Calculate AVG per dimension and keep data filtering

Dear Colleagues,

I am using below formula to calculate AVG processing time per vendor.
It works generally OK, but it always calculates an average from the whole available set of data. For example if we have 3 years history of invoice posting and I only want to see an average for year 2020, applying time selection filter does not change the result of this formula, which keeps calculation for 2018-2020. Is there any way to keep this AVG dynamic and alligned with current selections?

Thank you.

PU_AVG(DOMAIN_TABLE(“LFA1”.“NAME1”||“LFA1”.“SOURCESYSTEM”),
CASE
WHEN MATCH_ACTIVITIES(NODE[‘WF step: Remove Qty block’] )=1
THEN CALC_THROUGHPUT(FIRST_OCCURRENCE[‘Invoice posted’] TO LAST_OCCURRENCE[‘WF step: Remove Qty block’],
REMAP_TIMESTAMPS("_CEL_AP_ACTIVITIES".“EVENTTIME”, DAYS))

ELSE CALC_THROUGHPUT(FIRST_OCCURRENCE[‘Invoice posted’] TO LAST_OCCURRENCE[‘WF step: Price difference approval’],
REMAP_TIMESTAMPS("_CEL_AP_ACTIVITIES".“EVENTTIME”, DAYS))
END
)