[tw5] Filter by "how many tags of these" a tiddler has

Hello everyone and thank you for this very useful software.

I have a wiki of exam questions, and I tag them with tags like “Exam-N” to record that a question has been used in the Nth exam.
I want to build a page that lists the questions by their usage frequency, that is: used in 5 exams, in 4 exams, etc.

Right now I have a big map of filters that select all the possibile combinations (i.e.: for the 1-usage category, choose all tagged by Exam-1 but not the others, or by Exam-2 but not the others and so on) but obviously this approach will not scale. I have looked at solutions like this one: [[tw5] Filter tiddlers with exactly one tag. - #8 by EricShulman] but I don’t know how to filter the single tag names by prefix, and then how to count them.

For reference, what I want is something like this:

! Used 5 times

<<list-links filter:"[enlist{!!tags} <keep only tags starting with 'Exam-'> <count them> <keep tiddlers that score 5>" >>

The desidered result is that a tiddler tagged with, say “Exam-1,Exam-2,Exam-4,Exam-5,Exam-6” or “Exam-1,Exam-3,Exam-4,Exam-5,Exam-6” is listed, but one that only has “Exam-4,Exam-5” is not because its score is 2.

Can something like this be done?

Thank you in advance,

Michele

Try this:

! Used 5 times
<<list-links filter:"[all[]] :filter[enlist{!!tags}prefix[Exam-]count[]match[5]]">>

Notes:

  1. To find all tiddlers that match the filter, start with a filter run of [all[]]
  2. Next, you need to use the :filter[...] prefix to keep the tiddler titles that match your criteria. Without this prefix, the result of the 2nd filter run would just be the number “5”
  3. The :filter[...] filter run prefix also lets you use {!!tags} to examine the tags of each tiddler title retrieved by the preceding [all[]] filter run. Otherwise, {!!tags} would refer only to the tags field of the current tiddler (i.e., the one containing the <<list-links>> macro itself.)
5 Likes

Erics [all[]] :filter[...] to get the titles is very clever.

Continuing where he left off, here is an untested variant to list/categorize all the exams by how many times they’ve been used:

\define thefilter() [all[]] :filter[enlist{!!tags}prefix[Exam-]count[]match[$(no)$]]

<$list filter="[range[10]]" variable=no>
<$list filter="""[<thefilter>enlist-input[]count[]!match[0]]""" variable=NUL>

! Used <<no>> times
<$macrocall $name="list-links" filter=<<thefilter>> />
</$list>
</$list>

I’m not sure the enlist-input[] is necessary… but then, I’m not sure my whole externalization of the filter will work at all.

Works perfectly! Thank you very much!

This I think should be like this:

<$list filter="""[subfilter<thefilter>enlist-input[]count[]!match[0]]""" variable=NUL>