Evaluate all listed tiddler match a condition

Hi ,

if i have a normal list filter , that displays some tiddlers, how can i evaluate if all of them have a particualr field value , or basically all of them match a condition

<$list filter="[tag[HelloThumbnail][get[field1]match[1]]">

doing this shows the tiddlers matching the condition, but i want a “yes” or “no” confirming that they ALL match or not , is this possible

thank you

1 Like

Sounds like you are looking for something like this:

<$vars totCount={{{ [tag[HelloThumbnail]count[]] }}}
       matchCount={{{ [tag[HelloThumbnail]has[ribbon-text]count[]] }}}>


Total count: <<totCount>>

Has "ribbon-text" count: <<matchCount>>

Total count = match count? <$text text={{{ [<totCount>match<matchCount>then[Yes]else[No]] }}}/>

</$vars>

<$list filter="[tag[HelloThumbnail]]">
<$link/><br>
</$list>
1 Like

Thank you chalrlie,

i works , but i dont think i asked the correct question …

ok this is actually a continuation to this post Change current tiddlers field value based on tagged tiddlers field value

so i have some tiddlers tagged with other tiddlers, i want to know if the tagged tiddlers underneath have a particular field value , then return back to the original TAG tiddler and take an action on it .

so with the below data i wanted to know if Tiddler A or Tiddler B has any tagged tiddlers undernath that dont have a value of one , then take an action on Tiddler A or Tiddler B ,

Tiddler A Tags :dummy customfield1 = 1
Tiddler B Tags :Tiddler A customfield1 = 1
Tiddler C Tags :Tiddler A customfield1 = 1

Tiddler X Tags :dummy customfield1 = 1
Tiddler Y Tags :Tiddler X customfield1 = 1
Tiddler Z Tags :Tiddler X customfield1 = 1

Eric schulman helped me with the below ,

<$list filter="[tag[dummy]tagging[]] :filter[get[customfield1]!match[1]] +[tags[]tag[dummy]]"> which works great

but now , i want to know if all tiddlers undernath have a Value of 1 , then go back to tiddler A or B and take an action on them if the tiddlers tagged with them meet the condition.

so erics filter evaluates a single tagged tiddlers field value against the condition , but would not evaluate all tagged tiddlers

sorry if my explanation sounds convoluted,i really hope this makes sense

Nope, I can’t make heads or tails of that, so I am tapping out.

I’m not 100% sure that I understand, and if I do, I’m not sure it would be the most efficient thing to do (if the number of tiddlers involved is small that won’t matter). Could you just create a list of all the properly tagged tiddlers, then make a 2nd list (based on the first) of all the properly tagged tiddlers that also fulfill your field value condition and take the difference of the 2 lists? If the resulting list is empty, you have met the “all properly tagged tiddlers have the field value of interest” criterion.

Thank you all for your responses

Ok in a nutshell , i want something like an allMatch[] operator :slight_smile: , that doesnt check if a particular entry in a filter matches the condition , instead checks if all entries in a filter matches the condition, then returns all these entries

You could count the total number of tiddlers, then count the number that meet a condition and test the first number equals the second, if so all will meet the condition.

If you give a simple filter for all tiddlers, and a simple filter for the condition I will write the count check. I find it a little hard to extract these from your example.

I posted that kind of sample code earlier.

Thanks tones,

i am unable to use the count method , because my use case involves multiple hierarchies.

  • so a starlight filter like [tag[dummy]tagging[]count[]] would count 4 which is fine if i had one tiddler with 4 tiddlers tagged underneath it

  • but if i have 2 tiddlers and each have 2 tiddlers tagged underneath , i would need something to do individual checks for every branch and come back with an evaluation for the first branch and another for the second branch

  • so for instance in the below example only TiddlerX meet the condition of all tagged tiddlers underneath having the value “1” in their custom field , TiddlerA does not meet the condition

Tiddler A Tags :dummy customfield1 = 1
Tiddler B Tags :Tiddler A customfield1 = 1
Tiddler C Tags :Tiddler A customfield1 = 2

Tiddler X Tags :dummy customfield1 = 1
Tiddler Y Tags :Tiddler X customfield1 = 1
Tiddler Z Tags :Tiddler X customfield1 = 1

  • if i did [tag[dummy]tagging[]count[]] it would yield 3 , but what i actually need is “2” and “1” ,one for each branch , then some how do individual comparisons against the total number of tagged tiddlers for each branch ,then somehow go back to the original tiddlers to take the action i need on them

  • btw its only an example , i actually have way more than 2 hierarchies in my wiki , and what i am triying to achieve is to have a global button that when used , triggers an action on all tiddlers that have tagged tiddlers underneath with specific values.

  • the filter that Eric provided works great, because it looks for one specific criteria present in any of the tagged tiddlers , what i need now is to look for one specific criteria present in all of the tagged tiddlers , then use [tags[]tag[dummy] to revert back to the original tiddlers that i want to take the action on

i tried to visualize the problem to make it a bit easier for me to explain

  • Tiddler A hierarchy is the original problem that was solved by erics filter at the top of the image.
  • Tiddler X hierarchy is the new problem that i am struggling with

I think I understand your requirements. Does this restatement capture the core?

You want to process all tiddlers with a given tag, say dummy. For each such tiddler with that tag, say Tiddler A, you want to examine all tiddlers with that title as a tag, say Tiddler B and Tiddler C. If every tiddler in that list has our given condition (say, its customfield1 field has value 1.) , then you want to do one sort of processing. If any of them does not, then you want to do another sort of processing.

If that’s correct, then the following may help:

<$list filter="[tag[dummy]]">
  <$let 
    count={{{ [tag<currentTiddler>count[]] }}}
    matched={{{ [tag<currentTiddler>customfield1[1]count[]] }}}
    allMatch={{{ [<count>match<matched>then[✔️]else[❌]] }}}
  >
    <$link />: <<allMatch>> (<<matched>> of <<count>> tiddlers matched)<br/>
  </$let>
</$list>

I’ve hard-coded all the values customfield1 and 1. These could be made dynamic by wrapping the <$let ...> statement in a macro and adding parameters. The only differentiating behavior here is the existence of the checkmark or cross. But you should be able to do other things based on this.

You can download this and drag it onto a wiki to demonstrate the behavior:

AllMatch.json (1.9 KB)

The result might look like this:

4 Likes

In the example data that @paulgilbert2000 gave there is only one level deep. The first list of tiddlers and those that they tag. My suggested approach and @Scott_Sauyets worked solution should be enought.

If you wanted to apply this to a multi level heirachy the same idea of using two seperate counts and comparing them is still valid.

  • I seems to me multiple layer heirachies could only use this method using a special filter like kin or the more recent tags and tagging tree operators. Although I wonder if 5.3.0 offers new possibilities?

The general solution

  • one approach is to write tiddlywiki script to gather all the relavant tiddlers and collect the list in a variable. Once you have this list you can feed it into a new, or multiple filters and count or even add another condition.
    • I have recently raised my concern that storing a list of titles in a variable is restricted, by a few methods only returning the first item.
  • that is you break the problem down into simpler steps even if its not the most efficient approach, at least you get your answer.
1 Like

@Scott_Sauyet Thank you very much scott for helping out and putting effort in to this , its exactly what i wanted and works perfectly:)

@tony , well thank god the fuctionality was needed only for one level down, so for this one i am not using a kin or tagtree filter which made things simpler , i am actually also not clear on which methods allows storing a list in a variable and which dont.and i am always confused as to how to process a list