Also, I don’t think you can insert a macro like that into a filter, but maybe there’s been some update I missed. When I try it with my own test, I get back the actual text defining the macro.
totalfieldx is a variable containing filter syntax, NOT filter results
The sortsub filter operator takes filter syntax as it’s operand value. It then evaluates that syntax for each input item and sorts those items by the resulting values.
Similarly, [subfilter<totalfieldx>] is used in order to evaluate the totalfieldxsyntax and display the result for each item.
The $link widget needs the to=<<currentTiddler>> param to correctly link to the current title. If this param is omitted, it will try to link to a tiddler title based on the inner content of the $link widget, which in this case will include the totalfieldx value for the current title, resulting in a link to a missing tiddler.
Always be sure to properly match each widget or HTML element with a corresponding </$widgetname> or </HTMLelement>
Note also that I am not able to test this potential solution, since A) I don’t have the kin filter plugin installed, and B) I don’t have any example data to operate on. In the future, it would be much easier for others to test/debug any suggested solutions if you provide a link to an online TiddlyWiki as an MTC (“minimal test case”)… perhaps hosted at https://tiddlyhost.com
I think the use of “reduce” filter run in your original run was causing the sortsub operator to get confused. I simplified it to use the “sum” operator, and then used the “sort” filter run to do the sorting.
A subtlety with the subfilter operator is that it is not a constructor. So it needs something in front of it to give valid results. In this case, it appears to need to have the current tiddler set (thats what the “all[current]” does). This is somewhat unexpected, because in some cases the subfilter operator works without the preceding “all[current]”.
Tiddlywiki doesn’t sort numbers in numerical order by default: it looks at all the first digits, then all the second digits (if present) and so on. Replacing :sort with :sort:number should fix this behavior (and for simpler filter runs, the nsort operator does the same thing.)
The sort filter run operator is pretty new, and it’s one of the few that lets you modify its behavior through extended syntax. Here’s the documentation, in case you have any more complicated sorting needs!