Filter by Custom Field containing Tiddler name with spaces in it?

489 views
Skip to first unread message

OGNSYA

unread,
Jun 15, 2020, 5:39:33 PM6/15/20
to TiddlyWiki
I'm trying to filter a list by my own custom field "Status", which is a list of tiddler names, but it only works if the value has no space in it.

Here's my code (the tag part works fine):

[!is[system]tag[My Tag]status[My Status]]

If I remove the space from the "My Status" tiddler, and change the above to "MyStatus", it works.

What am I doing wrong? 
Shouldn't this work the same as with tags?

Thanks!

Mark S.

unread,
Jun 15, 2020, 6:09:01 PM6/15/20
to TiddlyWiki
If "status" is a list of tiddler names, then any of the names in the list that have spaces need to be like [[My Status]]. This is called a title list. And you can't search directly with status[....], because that method only matches fields with a single value. Instead use the "contains" operator, with the field status as a suffix. Like:

[!is[system]tag[My Tag]contains:status[My Status]]

HTH

OGNSYA

unread,
Jun 15, 2020, 6:29:01 PM6/15/20
to TiddlyWiki
Perfect! Thank you.

I did have the tiddler name as [[My Status]] in the custom field.
I was assuming that the tag field of a tiddler was simply a list of titles.
Since my custom field was also a list of titles, I assumed I could access it the same way.
I suppose it's not...

Now I'm stuck trying to filter based on a number in a custom field called "priority".
I'd like to only show tiddlers with priority equal or greater than "5"
Can I do that in a filter?

Mark S.

unread,
Jun 15, 2020, 7:09:29 PM6/15/20
to TiddlyWiki

The "compare" operator can let you make numeric comparisons:

OGNSYA

unread,
Jun 16, 2020, 6:04:46 AM6/16/20
to TiddlyWiki
Thanks! I did see that, but couldn't figure out how to actually use it.
Let's say I want to filter only tiddlers where the custom field priority is 5 or greater.

This works, but it's messy: 
[priority[5]] [priority[6]] [priority[7]] [priority[8]] [priority[9]] [priority[10]] +[!is[system]tag[My Tag]]

I understand that this, for example, returns 6, because 6 is greater than or equal to 5:
[[6]compare:number:gteq[5]]

However, I don't know how to use that in a filter.... 
As far as I understand, that first parameter should be a list of tiddlers... But then I'd be comparing the tiddler, not a specific field within it...
Which means I'd need to first test using only the value of that field, and then use that to filter.
I tried these, but none worked...

priority[[{{!!priority}}]compare:number:gteq[5]]
priority[[[{{!!priority}}]compare:number:gteq[5]]]
priority[[[field:priority]compare:number:gteq[5]]]

I figure there is probably a very simple solution to this that I'm missing.

Eric Shulman

unread,
Jun 16, 2020, 6:33:20 AM6/16/20
to TiddlyWiki
On Tuesday, June 16, 2020 at 3:04:46 AM UTC-7, OGNSYA wrote:
Thanks! I did see that, but couldn't figure out how to actually use it.
Let's say I want to filter only tiddlers where the custom field priority is 5 or greater.

Give this a try: 
[{!!priority}compare:number:gteq[5]]

Note that, in filter syntax, you use *single* brackets around references,
and except for the outermost square brackets around the whole filter run,
the brackets are part of the reference itself, where
[...] is for literal values, {...} is for field values, and <...> is for variables

So, for example, in addition to the above syntax for comparing with a literal value of "5",
you could compare with a value stored in another field:
[{!!priority}compare:number:gteq{!!minimum}]
or with a value from a variable:
<$vars minimum="5">
[{!!priority}compare:number:gteq
<minimum>]
</$vars>

hope this helps,

enjoy,
-e

OGNSYA

unread,
Jun 16, 2020, 7:07:28 AM6/16/20
to tiddl...@googlegroups.com
Thanks for that Eric. 
For some reason it didn't work for me...

This simple case works, for showing all tiddlers with importance set as 5:
(note I changed the field name from priority to importance)
[importance[5]]

I tried this, for showing all tiddlers with importance 5 or higher: 
[importance[{!!importance}compare:number:gteq[5]]]

I also tried just this:
[{!!importance}compare:number:gteq[5]]

Saq Imtiaz

unread,
Jun 16, 2020, 9:40:53 AM6/16/20
to TiddlyWiki
try [get[importance]compare:number:gteq[5]]

this assumes you want to compare a field with name importance

OGNSYA

unread,
Jun 16, 2020, 10:41:26 AM6/16/20
to TiddlyWiki
Thanks Saq.

I tried your suggestion and it did the filtering, however the output doesn't seem to be the actual tiddler list.

First, here's a simpler example that works for me:
<$list filter="[importance[5]]"><$view field="title"/><br/></$list>

This correctly outputs a list of all tiddlers with importance field equal to 5.
Tiddler A
Tiddler B
Tiddler D
Tiddler G
etc.

Below, my attempt to show all tiddlers with importance equal or greater than 5, based on the code you suggested:
<$list filter="[get[importance]compare:number:gteq[5]]"><$view field="title"/><br/></$list>

This returns a list of numbers, corresponding to the importance field, for each tiddler.
8
10
6
5
8
(etc...)

That is actually correct, considering it's only showing numbers 5 and above. However I'd like the output to be the tiddlers themselves (as in my simple example).
I'm probably doing something wrong. I just don't know what..

I also tried this:
<$list filter="[importance[[get[importance]compare:number:gteq[5]]]]"><$view field="title"/><br/></$list>

But it returns:
Filter error: Syntax error in filter expression


Saq Imtiaz

unread,
Jun 16, 2020, 11:06:04 AM6/16/20
to TiddlyWiki
<$list filter="[has[importance]]">

{{{ [{!!importance}compare:number:gteq[5]then{!!title}] }}}

</$list>

I also recommend you re-read what Eric has explained above regarding brackets in filters.

OGNSYA

unread,
Jun 16, 2020, 11:47:58 AM6/16/20
to TiddlyWiki
That works, thanks!

Could it be all done within the filter?
I want to use it as a filter for a TiddlyTables table. I think I can only configure a filter there. (see image attached)

Thanks for explaining things to me. I did read Eric's email. But I'm a beginner in TW , and not a strong coder (I can do very simple JS/HTML), so the language is still quite overwhelming to me.

OGNSYA

unread,
Jun 17, 2020, 6:35:01 AM6/17/20
to TiddlyWiki
Funny thing is that in the process of figuring that out I managed to implement by myself a cool real-time filter for my table.
I thought this would take ages to do.

Meanwhile, I can't figure out how to implement this thing I thought would be very simple (have a filter that outputs only tiddlers where a field is within a certain numerical range).

Saq Imtiaz

unread,
Jun 17, 2020, 7:11:20 AM6/17/20
to TiddlyWiki
This is usually done with nested lists.

What is the numerical range for importance? With a limited set of values there are other ways to approach this

Is it 0-10 and whole numbers only?

Saq Imtiaz

unread,
Jun 17, 2020, 7:40:32 AM6/17/20
to TiddlyWiki
If importance is in the range 0-10 and whole numbers only, the following will do what you want though it is not very elegant:

[importance[5]] [importance[6]] [importance[7]] [importance[8]] [importance[9]] [importance[10]]

OGNSYA

unread,
Jun 17, 2020, 7:41:32 AM6/17/20
to TiddlyWiki
The range is quite limited indeed (0-10, whole), so adding this to my filter works:
+[importance[5]] [importance[6]] [importance[7]] [importance[8]] [importance[9]] [importance[10]]

It just feels very messy. Also, I'll probably want to do more complex comparisons in the future...

OGNSYA

unread,
Jun 17, 2020, 10:47:23 AM6/17/20
to TiddlyWiki
Thanks @saq 

I just realized we sent almost the same thing at the same time :)
Reply all
Reply to author
Forward
0 new messages