Rank based an a field

Several tiddlers in my TiddlyWiki have a numerical value in a field ‘amount’.

I am displaying the amount of the current tiddler using:

Amount: {{!!amount}}

I want to display how many tiddlers have the field ‘amount’ set. I am doing this with:

<$text text={{{ [has[amount]count[]] }}} />

But I also want to know what is the rank of the current tiddler among all the tiddlers having ‘amount’ field set.

So, if ‘amount’ of TidA, TidB and TidC is set to 150, 100 and 200, TidA will get a rank 2, TidB will get a rank 3 and TidC will get a rank 1.

How do I get this rank?

You can do it using the filter operator sort(or similar operator) to order yours list of tiddlers.

https://tiddlywiki.com/#sort%20Operator

@Alvaro Thanks. Got the clue.

<$text text={{{ [has[amount]nsort[amount]allafter:include<currentTiddler>count[]] }}} />

does the trick!

1 Like