E.g. let's say a filter puts out the following:
Apple pear Orange
Pear
Orange banana
Orange grapefruit
How would you filter it further to result with something like this:
Orange 3
Pear 2
Apple
banana
Grapefruit
Thanks,
- Dave
Perhaps use the each filter operator to get a list of fruits without duplicates then within that use the count operator to get the number of each fruit.
I am on my phone, so I hope this narrative answer is enough.
Regards
Tony
A real chalenge without buttons etc, a good puzzel.
I will keep thinking about this.
Tony
Interesting challenge to do it without having to save values with a button.
There is also the count widget, and the math and formula plugins which may suport this.
But I have a hunch it can be done.
Tony
<$list filter="[all[current]fields[]]" variable="fieldname">
<$list filter="[all[current]get<fieldname>prefix[1]suffix[1]]" variable="dummy" >
<$list filter="[title<fieldname>getindex[origin]]" variable="origin">
<<origin>>:<$count filter=" <<origin>>"/><br>
</$list>
</$list>
</$list>
<$list filter="[all[current]fields[]]" variable="fieldname">
<$list filter="[all[current]get<fieldname>prefix[1]suffix[1]]" variable="dummy" >
<$list filter="[title<fieldname>getindex[origin]]" variable="origin">
<$action-setfield $field="aaa" $value="<origin>"/>
<<origin>>
</$list>
</$list>
</$list>
$value="<origin>"
$value=<origin>
$value="<<origin>>"
$value=<<origin>>
$value="$<origin>$"
$value=$<origin>$
but none of them resulted in a field "aaa" at all, let alone one filled with the proper content.
<$action-setfield field="aaa" value="<origin>"/>
i.e. I spotted that "field" and "value" didn't need the "$" like the "$tidder" would in the tiddlywiki.com examples
<$button>
<$list filter="[all[current]fields[]]" variable="fieldname">
<$list filter="[all[current]get
<fieldname>prefix[1]suffix[1]]" variable="dummy" >
<$list filter="[title<fieldname>getindex[origin]]" variable="origin">
<$action-setfield $field="aaa" $value=<<origin>>/>
<<origin>>
</$list>
</$list>
</$list>
</$button>
\define myresults()
<$list filter="[all[current]fields[]]" variable="fieldname">
<$list filter="[all[current]get<fieldname>prefix[1]suffix[1]]" variable="dummy" >
<$list filter="[title<fieldname>getindex[origin]]" variable="origin">
<<origin>>
</$list>
</$list>
</$list>
\end
!origin
<$button>
check
<$action-setfield $field="aaa" $value=<<myresults>>/>
</$button>
<$view field="aaa"/>
<$list filter="[title<fieldname>getindex[origin]]" variable="origin">
part, and then going back to the version with
<$action-setfield $field="aaa" $value=<<origin>>/>
Are carriage returns an issue with TW? They would be represented as the breaks between the sets of data coming from the data tiddlers...
<$button>
<$list filter="[all[current]fields[]]" variable="fieldname">
<$list filter="[all[current]get<fieldname>prefix[1]suffix[1]]" variable="dummy" >
<$list filter="[title<fieldname>
getindex[origin]]" variable="origin">
CONVERT ORIGIN INTO TITLE LIST
<$LIST STEP THROUGH ALL POSSIBLE ORIGIN TYPES>
WHEN FIELD POSSIBLE ORIGIN MATCHES CURRENT ORIGIN, ADD TO ORIGIN FIELD OF TALLIES (e.g. 2018-08-06.tallies!!cbm = l.stork.right
chest.fall )
</$LIST>
</$list>
</$list>
</$list>
<$LIST>
GO THROUGH ALL FIELDS (less created, modified, type) OF 2018-08-06.tallies AND FIND COUNTS
PUT COUNTS IN stats TIDDLER (e.g. 2018-08-06.stats!!cbm = 3)
</$LIST>
</$button>
NOW YOU CAN EXTRACT ORIGINS AND COUNTS FROM 2018-08-06.stats AND SORT DIRECTLY
\define sort-me()
<$list filter="[all[]tag[fruit]!sort[]]" variable=fruit>
<$list filter="[tag<fruit>count[]]" variable=num>
<<num>>-<<fruit>>
</$list>
</$list>
\end
<$wikify name=sort-filter text="<<sort-me>> +[!nsort[]]">
<$list filter=<<sort-filter>> >
</$list>
</$wikify>
And yes there are still storks... The stork test: patient stands on one leg and closes their eyes, if the direction they sway to on one leg matches the direction they sway to on the other leg then they may have a "blown fuse" in the vestibular nucleus of the side they sway to... But don't try this at home -falling down is bad for your health ;)
\define myresults()
<$list filter="[all[current]fields[]]" variable="fieldname">
<$list filter="[all[current]get<fieldname>prefix[1]suffix[1]]" variable="dummy" >
<$list filter="[title<fieldname>getindex[origin]]" variable="origin">
<$list filter="[title<fieldname>getindex[origin]count[]]" variable=num>
<<num>>-<<origin>>
</$list>
</$list>
</$list>
</$list>
\end
<$wikify name=sort-filter text="<<myresults>> +[!nsort[]]">
<$list filter=<<sort-filter>> >
</$list>
</$wikify>
\define cat-origin-link() <$text text="[[$(origin)$]]"/>
\define get-origins-list()
<$list filter="[all[current]fields[]]" variable="fieldname">
<$list filter="[all[current]get<fieldname>prefix[1]suffix[1]]" variable="dummy" >
<$list filter="[title<fieldname>getindex[origin]]" variable="originlist">
<$list filter=<<originlist>> variable="origin">
<<cat-origin-link>>
</$list>
</$list>
</$list>
</$list>
\end
\define cat-origin-uniq-link() <$text text="[[$(fieldname)$@$(origin)$@]]"/>
\define get-origins-list-uniquified()
<$list filter="[all[current]fields[]]" variable="fieldname">
<$list filter="[all[current]get<fieldname>prefix[1]suffix[1]]" variable="dummy" >
<$list filter="[title<fieldname>getindex[origin]]" variable="originlist">
<$list filter=<<originlist>> variable="origin">
<<cat-origin-uniq-link>>
</$list>
</$list>
</$list>
</$list>
\end
\define cat-count-origin() <$text text="[[$(count)$-$(origin)$]]"/>
\define get-wikified-counts()
<$wikify text="<<get-origins-list>>" name="list-filter">
<$list filter=<<list-filter>> variable=origin>
<$wikify name="count-filter" text="<<get-origins-list-uniquified>> +[regexp[.*@<<origin>>@$]count[]]">
<$list filter=<<count-filter>> variable=count>
<<cat-count-origin>>
</$list>
</$wikify>
</$list>
</$wikify>
\end
! ORIGIN COUNTS
<$wikify text="<<get-wikified-counts>> +[nsort[]]" name="filter-counts">
<$list filter=<<filter-counts>> variable="count-origin">
<<count-origin>><br/>
</$list>
</$wikify>
I'll try to get this going tomorrow and let you know how it went :)
Hopefully I'll at some point generalize this so others can use it too (not sure how many other use cases like this there are)
- Dave
\define cat-count-origin() <$text text="[[$(count)$-$(origin)$]]"/>
\define cat-count-origin() <$text text="[[$(count)$-[[$(origin)$]]]]"/>
! ORIGIN COUNTS
<$wikify text="<<get-wikified-counts>> +[nsort[]]" name="filter-counts">
<$list filter=<<filter-counts>> variable="count-origin">
<$list filter="cbm cbm.midline cn8 [[opp motor cortex]] [[pmrf]]" variable="origintype">
<$wikify name=filter-for-origin text="[title[<<count-origin>>]regexp[-<<origintype>>$]]" >
<$list filter=<<filter-for-origin>> variable=originname>
<$link to=<<origintype>>><<count-origin>> </$link><br/>
</$list>
</$wikify>
</$list>
</$list>
</$wikify>
! ORIGIN COUNTS
<$wikify text="<<get-wikified-counts>> +[nsort[]]" name="filter-counts">
<$list filter=<<filter-counts>> variable="count-origin">
<$wikify text="<<get-origins-list>>" name="list-origins-list">
<$list filter=<<list-origins-list>> variable="origintype">
<$wikify name=filter-for-origin text="[title[<<count-origin>>]regexp[-<<origintype>>$]]" >
<$list filter=<<filter-for-origin>> variable=originname>
<<count-origin>> <$link to=<<origintype>>><<origintype>></$link> <br/>
</$list>
</$wikify>
</$list>
</$wikify>
</$list>
</$wikify>