\define count-items(filter) <$list filter="$filter$ +[count[]]" variable=
result><<result>></$list>
\define sum-field(fieldname,filter)
<$set name=filter value="$filter$" emptyValue="[has:field[$fieldname$]]">
(= sum([has[$fieldname$]] +[get[$fieldname$]]) =)
</$set>
\end

You provide the count items with a filter and it will count the members in 
that set

<<count-items "filter">>

You need Evans Formula Plugin for 
You provide the sum-Field with a fieldname and it will sum the contents of 
that field all tiddlers with that fieldname
<<sum-field "fieldname">>

Or provide a filter to limit the tiddlers
<<sum-field "fieldname" "filtername">>




hubertgk

Since I went down this line for myself I created the following two macros 
you can place in a tiddler tagged $:/tags/Macro


Regards
Tony 
On Tuesday, June 19, 2018 at 1:54:10 AM UTC+10, hubertgk wrote:
>
> Hi,
>
> Using Evan Balster's <<formula>> macro, I'm trying to sum the numerical 
> output of a <$list> filter but each of the list items is processed 
> separately.
>
> For example, if the output of my list is 2 2 1 and I try to sum that with 
> 5 using <<formula>>, then each of the arguments is summed in isolation and 
> I get "7 7 6" (2+5, 2+5, 1+5) instead of "10" (2+2+1+5).
>
> So my question is, how can I transform the output of a list filter (all 
> returned arguments) into a single array containing those arguments?
>
> Here's my code. I've provided more of it for context but it's not 
> necessarily relevant to my question (I'm having a list of values returned 
> based on a search performed on indexes in a data tiddler. The values are 
> numbers and the output is a list).
>
> \define test()
> <$list filter="[[_data]getindex[$(matching_indexes)$]]" variable=
> "dataTiddler">
> <$set name=arguments value=<<dataTiddler>>>
> <<test2>>
> </$set>
> </$list>
> \end
>
> \define test2()
> <<formula "sum(($(arguments)$), 5)">>
> \end
>
> <$set name=matching_indexes value=searchterm>
>
> <<test>>
>
> </$set>
>
>
> Thank you very much for your ideas!
>
> Best,
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/56b32eb7-5b92-499d-af86-65f70f7a1f05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to