Convert Static Query Into Dynamic Query Based on Current File Properties

I don’t remember how this worked:

Well, I do have an upgraded version of it in my vault, but I cannot (will not) deconstruct it.
The linked material will get you going, if with some AI help.