Need some help with filter expression sorting

Hi there!
Faced an issue I can’t work around, so I am desperately looking for any advice

Here is the situation:
I am trying to make a simple TW for some statistics for a card game. So by design we have 2 main entities: Deck and Match. They are tagged accordingly. Then, we have a Tiddler on a role of match creator, where I can pick or create Player (separete tiddler), game-mode, etc.

And when I hit button, new “Match” tiddler is created, which has all info about that match stored in fields: players, decks, who won, etc. There is also a work around for tracking date of such matches if the tiddler was created several days after the exact match with DatePicker plugin, I use action-setfield to edit created field of the created “Match” tiddler.

So in that lil “Match” tiddler I have pretty much everything I need for the task described later: Date of match (created field of “Match” tiddler) and Decks used in this match (fields Deck1,Deck2…Deck6) which has value of “Deck” tiddler title.

And now I want to make a list of Decks, sorted by the day they were played.

I dunno why, but expression below doesn’t work with list widget.
[tag[Deck]] :sort:date[tag[Match]search:Deck1,Deck2,Deck3,Deck4,Deck5,Deck6{!!title}get[created]maxall[]format:date[DDth MMM YYYY]]

But it works for “Deck” tiddler to show date of the last macth with this deck:
{{{ [tag[Match]search:Deck1,Deck2,Deck3,Deck4,Deck5,Deck6{!!title}get[created]maxall[]format:date[DDth MMM YYYY]] }}}

<currentTiddler> doesn’t work either.

Here are tiddler examplessort list example.json (4.3 KB)

Welcome to the forum, Janus!

First off – don’t use the “created” or “modified” fields for your own purposes. It will confuse the core, and we don’t want to do that.

There’s a subtlety about the sort filter run expression … and most of the filter run expressions. They take the title in the previous list an invisibly put it at the start. So internally, your expression looks like this:

sort:date[<currentTiddler>tag[match]search:Deck1, ...

This means your tag operation is only going to work on one tiddler – the one that was passed. So you need to tell the tag operator to search on everything:

<$list filter="[tag[deck]]:sort:date[all[tiddlers]tag[match]search:Deck1,Deck2,Deck3,Deck4,Deck5,Deck6{!!title}get[created]maxall[]]" counter="counter">
<<counter>>. <$link to={{!!title}}/> last match: {{{ [tag[match]search:Deck1,Deck2,Deck3,Deck4,Deck5,Deck6{!!title}get[created]maxall[]format:date[DDth MMM YYYY]] }}}<br>

Have fun!

1 Like

Thank you so much for your answer, Mark!
Actually, by now I have already found that in previuos post^^

And about created/modified fields - ok, thanks fo advice, I can easly fix it with just another field. The main idea behind that monstrocity is that I didn’t want any Match data to be stored at Deck tiddler.