Filter usage, works one way, but not another

I have a tiddler that attempts to show a list of all “event” tiddlers shared by two “person” tiddlers.

So, given two people John Smith and Susan Wilson I want to list all events that they share.

Event tiddlers have a “people” title field. In this simple case the following filter works (where is a variable of person 1 and is a variable of person 2):

[tag[event]contains:people<p1>contains:people<p2>]

I also have an “event-role” tiddler. This is used to associate people to an event with a role. These tiddlers define the role this person had in the event. It has two title fields: “event” (title field of the event) and “people” (title field lists all people with this role in the event). Therefore, getting the shared events is a bit more complicated.

The following filter gets all the shared events within the same role (this works).

[tag[event-role]contains:people<p1>contains:people<p2>get[event]enlist-input[]]

Then I wanted to get a list of events of people in the event tiddler vs those found in an event role. I first wrote this, but it did not work:

[tag[event]contains:people<p1>tag[event-role]contains:people<p2>get[event]enlist-input[]]

For some reason I elected to reverse the filter logic to the following (and found this did worked):

[tag[event-role]contains:people<p2>get[event]enlist-input[]tag[event]contains:people<p1>]

Why?

I suspect it is something to do with my usage of the “get”.

Is it because it is performing the “get” operator on both the “tag[event] and tag[event-role]”? If so, things get more complex with my next step…

My next step was to get shared events where the two people are found in different “event-role” tiddlers:

[tag[event-role]contains:people<p1>get[event]enlist-input[]tag[event-role]contains:people<p2>get[event]enlist-input[]]

And, this does not work either.

Any ideas? Thank you,

Craig

Are your event tiddlers also tagged with event-role?

[tag[event]contains:people<p1>tag[event-role] corresponds to:

  • tiddlers with the tag event;
  • that contain p1 in the field people;
  • and also have the tag event-role.

You may also find the :intersection filter run prefix useful:
https://tiddlywiki.com/#Intersection%20Filter%20Run%20Prefix

1 Like

Correction… NO.

Person tiddlers are tagged with “person” (not that this is needed for this case).

Event tiddlers are tagged with “event” and event roles are tagged with “event-role”.

I’ll have a look at “:intersection”. Thank you.

Hopefully this explains the filter that did not yield the expected results, it was testing event tiddlers for the tag event-role.

It does. Exactly what I needed. Thank you.

Craig, you are further ahead than me on these filters. I do usually resort to trial and error and Googling snippets to see if anyone else has figured out the syntax.

Otherwise, strip it back to just the bare bones of what you are trying to do and post online … explaining what doesn’t work and what you are trying to do.

Graham

I’d like to take an advanced course on filters. I learn a bit more as time goes on. I lack advanced concepts. In many cases, there is more than 1 way to write a filter. I end up writing something that is more complex than it needs to be. I’m sure I have used nested list widgets when 1 would do the job.