Question on enumerating levels of Descendancy

How can you tell where a Note is located in terms of how many layers deep it lies within a root-level container?

If there’s no system attribute, is it reasonable to parse the $Path for number of "/"s and save to a $Levels user Attribute? Of course, this may return inaccurate results if $Name attributes contain one or more "/"s.

Any better way?

$OutlineDepth is what you want.

If there weren’t a built-in attribute, your approach to parsing $Path would work. Or collect(ancestors,$Name).count.

1 Like

This works perfectly for my question; which was mis-phrased, sorry about that!

What I’m trying to find out is by looking at my root-level containers, can I tell how many levels down each of their sub-containers go? (I’m trying to stay on top of user proliferation)

I am tempted to guess out loud something like collect(descendents,$Name).count…? But that tells me the total number of descendants, not the # of levels of sub-containers.

Have you tried $OutlineDepth? Note that is it 1-based, i.e. root-level notes are at outline depth of 1.

Sorry, previous answer posted whist I was writing. Meanwhile…

Use this:

$MyNumber = collect(descendants, $OutlineDepth).max;

Use as a stamp on a container note and its $MyNumber value will then show how deep its descendants go. The stamped note doesn’t need to be a root container, as the descendants designator simply returns all items below the currently selected item

1 Like

Thanks @mwra! Works a charm. And an insight into intelligent juxtaposition of expressions to yield results.

1 Like

I’ve just updated this article and accompanying image to help explain outline depth and designators and how they relate to a document’s hierarchy.

1 Like