I don't think that QV knows an answer to something like
if (aggr(count(..),Parent) > 0, ..)
since aggr will not necessarily return only one value. So the comparison larger than zero may not be unambigouus.
I am not really sure what you are trying to achieve. Anyway, I would start off with small pieces of code and build the total expression bottom up.
Not sure this is of any help,