It was my mistake; I didn’t understand the main problem - subtasks! I don’t have those in my case.
I believe that @holroy’s solution will give you what you want.
I was afraid to try this, that you don’t bring bad luck to my “formula” … done, still worked. But, as I mentioned, I don’t have subtasks.
Cheers, Marko