Tinderbox Forum

Count number of alias in a map view

In map view , I’ve multiple alias of a given note , is it possible to count but restrict the counting to particular map only ?

Let’s assume the note is ‘Note X’ and it, and two aliases of the note are all one map at path Some/Map and 3 aliases elsewhere in the TBX. Thus the doc has one original of the note and a total of 5 aliases. But, we want the number of aliases in the map of Some/Map and only aliases, so that we get a count of 2 items expect 2 items

A stamp:

$MyNumber = collect(find($Name=="Note X" & $IsAlias==true & $Container=="/Some/Map/"),$Path).count;

gives a count of 2.

Basically think through the discrete parts of the logic:

  • the title of the note as this finds originals and or aliases (but also duplicate-named notes, so allow for that)
  • do you want originals, or only aliases, or both
  • What is/are the unique path(s) to the parent ($Container) of the items you want to match.

(Tested in v8.9.2)

1 Like

HI Mark,

Thanks for the answer. Stamps makes it very clear. Having container and $IsAlias solves query.

If I may ask what purpose does $Path serve in the formula ?

Collect has to list an attribute value (the second input parameter) for each found note. I could have equally have used $ID. I wanted an attribute I knew to be a unique value. Though collect returns a list (i.e. un-duped) , I think it still useful to assume that each returned value in this context should be unique.

Indeed $ID would be better, as aliases in the same map with have the same $Path but different $ID values. I nice explanation for why $ID is needed as an attribute. An alias has the same $Name and potentially the same $Path as its original.

Aside, if using collect to find notes upon which to each, e.g. by using .each(){} on the output list, then $Path is a good thing to collect.

Does that clarify things?

1 Like