math operators don't sum if same value

46 views
Skip to first unread message

Dave

unread,
Dec 30, 2019, 7:33:17 PM12/30/19
to TiddlyWiki
I have this macro that sums up values from three different fields:
\define vassum2(here mynow)
VAS total
: {{{[title[$here$]get[vashi.$mynow$]] [title[$here$]get[vaslo.$mynow$]] [title[$here$]get[disabil.$mynow$]] +[sum[]]}}}
\end

\define vassum()
<$macrocall $name=vassum2 here="$(currentTiddler)$" mynow={{mynow!!my-now}} />
\end

<<vassum>>

It works great as long as each of the three numbers is unique, but if for example the values are 8,3 and 3, then the total is presented as 11, not 14

Is there a work-around for this?


Thanks,
- Dave

Eric Shulman

unread,
Dec 30, 2019, 9:11:44 PM12/30/19
to TiddlyWiki

By default, items in a list are "dominantly appended", which automatically "de-duplicate" the results, so that individual items will appear only once in the resulting list

Of course, as you have discovered, this is not appropriate when using math operators.  To work around this, you can use the "=" prefix in front of each filter run, like this:
{{{ =[title[$here$]get[vashi.$mynow$]] =[title[$here$]get[vaslo.$mynow$]] =[title[$here$]get[disabil.$mynow$]] +[sum[]] }}}

enjoy,
-e

Dave

unread,
Dec 30, 2019, 10:01:59 PM12/30/19
to TiddlyWiki
Thanks again Eric - that fixed it :)
Reply all
Reply to author
Forward
0 new messages