All of your "aaa" fields to be summed are just in the one tiddler. That
changes everything.
I thought your "aaa" fields were spread across multiple tiddlers. Yeah, my
solution is for a much more complex problem.
On Thursday, December 16, 2021 at 9:04:57 AM UTC-4 Dave Kor wrote:
> Thanks for the info. After looking through my stuff I realized I had
> already solved this several months ago. The solution is rather simple:
>
> {{{ [[Data]fields[]prefix[aaa]] :map[[Data]get<currentTiddler>] +[sum[]]
> }}}
>
> On Thursday, December 16, 2021 at 11:43:16 AM UTC+8 [email protected]
> wrote:
>
>> ARG! I forgot to mention, that "regexp" bit might need some tweaking so
>> that the pattern gets all, but only, the fields you are interested in.
>>
>> On Wednesday, December 15, 2021 at 11:41:18 PM UTC-4 Charlie Veniot wrote:
>>
>>> Hello Dave,
>>>
>>> That is no trivial thing you're trying to do. Well, maybe somebody has
>>> a trivial solution.
>>>
>>> But what a great "Brain Age" game !!!
>>>
>>> So in the meantime, download the attached and drag into tiddlywiki.com
>>> to import the tiddlers and give you an opportunity to study what I've done.
>>>
>>> I've pasted the code below as reference for anything murky that needs
>>> some serious explaining.
>>>
>>> It is not a trivial affair to require dynamic identification of fields
>>> that need to be summed.
>>>
>>> Much easier to specify the exact fields. Then you have a simple filter
>>> like "[get[aaa1]] [get[aaa2]] ... etc. ... [get[aaaX]] +[sum[]]"
>>>
>>> Since we do not know the exact field names, then we have to dynamically
>>> build that filter above. (As per the *highlighted magic* in the code
>>> below)
>>>
>>>
>>> Ignoring the starting and ending "pre" tags. I'm trying that to see if
>>> the code below shows up okay in TiddlyTalk (which is finicky with this kind
>>> of stuff.)
>>>
>>> <pre>
>>>
>>> \define p1() [get[
>>> \define p2() ]]
>>> \define p3() +[sum[]]
>>>
>>> <$list variable="thisField" filter="[fields[]regexp[aaa]]">
>>> sum of <<thisField>> values:
>>> <$list filter="[get<thisField>sum[]]">
>>> {{!!title}}
>>> </$list><br>
>>> </$list>
>>> *<$vars thisDynamicFilter={{{
>>> [fields[]regexp[aaa]addprefix<p1>addsuffix<p2>] [<p3>] +[join[ ]] }}}>*
>>> <$list filter={{{ *[<thisDynamicFilter>]* }}}>
>>> ''total:'' <<currentTiddler>>
>>> </$list>
>>> </$vars>
>>>
>>> </pre>
>>>
>>>
>>>
>>>
>>>
>>> On Wednesday, December 15, 2021 at 10:40:06 PM UTC-4 Dave Kor wrote:
>>>
>>>> Hello, I am storing numeric data in tiddler fields and I'd like to
>>>> select fields that start with lets say "aaa" and sum all their values
>>>> together. I know I can use filters to select the fields i need using
>>>> something like {{{ [[Data]fields[]prefix[aaa]] }}} and I can probably sum
>>>> their values together using the sum[] operator.
>>>>
>>>> However, I am stumped as to how I can get the field's value. I know the
>>>> final filter would look something like {{{ =[[Data]fields[]prefix[aaa]???]
>>>> +[sum[]] }}} I just do not know what operator to use to get the field
>>>> values.
>>>>
>>>>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/c5dead7b-7694-4c8a-97c1-35a2be56bf13n%40googlegroups.com.