For this type of calculation usually you need to use LAC-W functions.
You need to use PRE_AGG in the numerator and PRE_FILTER in the denominator. It’s covered in this video. I put the timestamp for you.
Another more recent video about level aware calculations: