Also, if you insist in having the data as part of the document in a “unstructured” form like this:
Q:: 456
A:: ()
tag:: #one
Q:: 789
A:: ()
tag:: #two
Q:: 128
tag:: #one
then you can use the following dataviewjs
:
let transpose = m => m[0].map((x,i) => m.map(x => x[i]));
let p = dv.pages('"TE"')
let result = transpose([p.Q, p.tag])
result = result.filter(x=>x[1] && x[1].contains("one"))
dv.table(["Q", "tag"], result)
which produces:
but I find this approach very brittle because it relies on the order in which Q
and tag
appear. If, for example, the second group with "Q:: 789"
was missing a tag, then the document will have three Q and only two tags, so that the correspondence Q[0] → tag[0], Q[1] → tag[1], Q[2]-> tag[2] will be broken.