Sort data view related list by number of tag matches

What I’m trying to do

I have set up a related template very similar to one on this previous thread Dataview: List related notes grouped by tags - #3 by alltagsverstand

I am trying to update my dataview syntax - so it sorts by the number of tag matches (the more tag matches should appear at the top of the page etc)

Here is the existing code - so trying to update amend the bit bolded below.

TABLE 
	join(file.etags) as Tags,
	join(tagmatches) as Matches,
	file.cday AS "created"

FLATTEN 
list(filter(file.etags, (t) => econtains(this.file.etags, t))) as tagmatches

WHERE length(tagmatches) > 0 AND file.path != this.file.path

**SORT tagmatches ASC**

Things I have tried

I am very much a copy and paste coder and have no idea where to start with this, any help much appreciated

Did you try with just SORT length(tagmatches) ASC ? I think that should do the trick for you.

Thank you - this works, the only change was to make it DESC rather than ASC

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.