The confusion of word count

Ok. An important note to start, and without meaning to sound pedantic, but attribute names are case-sensitive. So if want the value of attribute ‘WordCount’ you can’t use $wordcount, it must be $WordCount. I get what you mean above but failure to use the correct case in code could be one reason your experiments are failing.

Anyway, I’ve just posted a fairly extensive demo that I think covers this here, in answer to a separate question by you on this same topic.

But briefly, to get the sum of the $WordCount of all children (and only children) and strore it in attribute ‘MyNumber’:

$MyNumber = sum(children,$WordCount);`

but to get a count for all descendants and not just children, you need to use:

$MyNumber = sum(descendants,$WordCount);`

The terms ‘children’ and ‘descendants’ here is using action code designators, on which you may wish to read up.

I this also covered in the demo to which I linked, and uses Display Expressions.