I assume there is a simple answer to this, but I don’t know (or remember) what it is, and can’t immediately find it in the material:
I have a large number of notes in a container, and the notes all have a Boolean attribute – let’s call it $CountMe.
I want to display, in the $Text of the parent container-note, a count of how many of the child notes have $CountMe set to true. For instance, if there are 100 notes total, and 25 have that attribute set, I’d like to see 25.
If I didn’t care about that attribute, I could just use $ChildCount to produce a total of all child notes. If I were wanting to get the actual values for the notes, I could use collect_if I understand each of these procedures.
But what is the equivalent to $ChildCount(if) or childcount_if (knowing that neither of those is the right way). How do I find the number of child notes meeting a condition? Thanks.
This doesn’t work for me as a rule or edit - and likely for the same reason the new code doesn’t work because the if result doesn’t set it’s output to anything. Therefore I suspect you are using a display expression, rather than a rule. The latter is relevant because the display expression is intended to be a single (and ideally non-complex) single expression. Thus you needs to split the new code. Set the note (or prototype’s) $Rule to:
$MyNumber = sum_if(children,$CountMe==true,1);
Set the $DisplayExpression to:
if($ChildCount){$Name+" ("+$ChildCount+") and "+ $MyNumber + " urgent tasks" }else{$Name};
And it works - at least it does when tested here in v7.2.2.
I’ve updatedmy page on Display Expressions to reflect some of the issues raised above, such as not trying to stick multiple expressions into $DisplayExpression.