# [tw] Re: How to calculate (sum, avg) with fields and store the result in an other field?

```I totally agree.

Nonetheless, thanks to any contribution to this issue, maybe it helps
others.```
```
Here is the solution, I made:

<\$fieldmangler>
<\$list filter="[is[current]tag[Aktiv]]">
<\$button message="tm-remove-tag" param="Aktiv">&not;Aktiv</\$button>
</\$list>
<\$list filter="[is[current]!tag[Aktiv]]">
</\$list>
</\$fieldmangler>
<\$fieldmangler>
<\$list filter="[is[current]tag[m]]">
<\$button message="tm-remove-tag" param="m">&not;m</\$button>
</\$list>
<\$list filter="[is[current]!tag[m]]">
</\$list>
</\$fieldmangler>
<\$fieldmangler>
<\$list filter="[is[current]tag[w]]">
<\$button message="tm-remove-tag" param="w">&not;w</\$button>
</\$list>
<\$list filter="[is[current]!tag[w]]">
</\$list>
</\$fieldmangler>
<\$fieldmangler>
<\$list filter="[is[current]tag[FW51]]">
<\$button message="tm-remove-tag" param="FW51">&not;FW51</\$button>
</\$list>
<\$list filter="[is[current]!tag[FW51]]">
</\$list>
</\$fieldmangler>
<\$fieldmangler>
<\$list filter="[is[current]tag[FW61]]">
<\$button message="tm-remove-tag" param="FW61">&not;FW61</\$button>
</\$list>
<\$list filter="[is[current]!tag[FW61]]">
</\$list>
</\$fieldmangler>
<\$fieldmangler>
<\$list filter="[is[current]tag[FW71]]">
<\$button message="tm-remove-tag" param="FW71">&not;FW71</\$button>
</\$list>
<\$list filter="[is[current]!tag[FW71]]">
</\$list>
</\$fieldmangler>
<\$fieldmangler>
<\$list filter="[is[current]tag[Facharbeit]]">
<\$button message="tm-remove-tag"
param="Facharbeit">&not;Facharbeit</\$button>
</\$list>
<\$list filter="[is[current]!tag[Facharbeit]]">
</\$list>
</\$fieldmangler>
<!-- Berechne die Summen für alle tiddler, die mit FW51 getaggt sind. Das
kann später der tag ctr sein.-->

{{!!title}}

[[Wirtschaftsinformatik]]

US01 KA01 + KA02: <\$edit-text field='fw51-wi-ka01' size=2/> + <\$edit-text
field='fw51-wi-ka02' size=2/> = {{!!fw51-wi-ka1u2}}<br>
US02 KA03 + KA04: <\$edit-text field='fw51-wi-ka03' size=2/> + <\$edit-text
field='fw51-wi-ka04' size=2/> = {{!!fw51-wi-ka3u4}}<br>
//= {{!!fw51-wi-ka1b4}} Punkte Zwischenzeugnis// <br>

MS01 KA05 + KA06: <\$edit-text field='fw51-wi-ka05' size=2/> + <\$edit-text
field='fw51-wi-ka06' size=2/> = {{!!fw51-wi-ka5u6}} <br>
= ''{{!!fw51-us-os-wi-summe}}'' Punkte Abschlusszeugnis<br>

Päd. Punkte Abschlusszeugnis WI: <\$edit-text
field='fw51-wi-zeugnis_abschluss' size=2/><br>

<\$button>WI: Aktualisieren und Speichern
<\$action-sumfield2 \$filter='[tag[FW51]]' \$sumfield='fw51-wi-ka01'
\$sumfield2='fw51-wi-ka02' \$storefield='fw51-wi-ka1u2'/>
<\$action-sumfield2 \$filter='[tag[FW51]]' \$sumfield='fw51-wi-ka03'
\$sumfield2='fw51-wi-ka04' \$storefield='fw51-wi-ka3u4'/>
<\$action-sumfield2 \$filter='[tag[FW51]]' \$sumfield='fw51-wi-ka1u2'
\$sumfield2='fw51-wi-ka3u4' \$storefield='fw51-wi-ka1b4'/>
<\$action-sumfield2 \$filter='[tag[FW51]]' \$sumfield='fw51-wi-ka05'
\$sumfield2='fw51-wi-ka06' \$storefield='fw51-wi-ka5u6'/>
<\$action-sumfield2 \$filter='[tag[FW51]]' \$sumfield='fw51-wi-ka1u2'
\$sumfield2='fw51-wi-ka3u4' \$storefield='fw51-us-wi-summe'/>
<\$action-sumfield2 \$filter='[tag[FW51]]' \$sumfield='fw51-us-wi-summe'
\$sumfield2='fw51-wi-ka5u6' \$storefield='fw51-us-os-wi-summe'/>
</\$button>

---

{{!!title}}

[[Controlling]]

MS02 KA01 + KA02: <\$edit-text field='fw51-ctr-ka01' size=2/> + <\$edit-text
field='fw51-ctr-ka02' size=2/> <br>//= {{!!fw51-ctr-ka1u2}} Punkte
Zwischenzeugnis// <br>

OS01 KA03 + KA04: <\$edit-text field='fw51-ctr-ka03' size=2/> + <\$edit-text
field='fw51-ctr-ka04' size=2/> = {{!!fw51-ctr-ka3u4}} <br>
= ''{{!!fw51-ctr-summe}}'' Punkte Abschlusszeugnis<br>

Päd. Punkte Abschlusszeugnis CTR: <\$edit-text
field='fw51-ctr-zeugnis_abschluss' size=2/><br>

<\$button>CTR: Aktualisieren und Speichern
<\$action-sumfield2 \$filter='[tag[FW51]]'| \$sumfield='fw51-ctr-ka01'
\$sumfield2='fw51-ctr-ka02'| \$storefield='fw51-ctr-ka1u2'/>
<\$action-sumfield2 \$filter='[tag[FW51]]'| \$sumfield='fw51-ctr-ka03'
\$sumfield2='fw51-ctr-ka04'| \$storefield='fw51-ctr-ka3u4'/>
<\$action-sumfield2 \$filter='[tag[FW51]]'| \$sumfield='fw51-ctr-ka1u2'
\$sumfield2='fw51-ctr-ka3u4'| \$storefield='fw51-ctr-summe'/>
</\$button>

And this is the (button based) solution only for adding the percentage
based points, not for the points themselves, not for the grades.

Automatically calculating values in the fields and in the tiddler like this
example would be a great simplification:

{{!!schnitt}}=({{!!field1}}+{{!!field2}}+{{!!field3}}+{{!!field4}})/4

To comfortably calc with (more than two) fields is often needed. Perhaps
some day a developer will see this problem and solve it. Let me know. ;-)

Greetings,

Uwe

Am Mittwoch, 2. August 2017 22:21:07 UTC+2 schrieb @TiddlyTweeter:
>
> Welcome to the club of non-functioning math in TW.
>
> Its a mess of half solutions.
>
> Josiah
>
>
> Uwe wrote:
>>
>> in some tiddlers I have some (< 20) fields with numbers in them, ie
>> {{!!field1}}=2, {{!!field2}}=4 and {{!!field3}}=5 and so on.
>>
>> I imported \$:/plugins/mklauber/math.js
>> <http://mklauber.github.io/tiddly-mathjs/#%24%3A%2Fplugins%2Fmklauber%2Fmath.js>
>>
>> from http://mklauber.github.io/tiddly-mathjs/
>>
>> Using <\$calc>, I *cannot *add the sum of these three fields
>> {{!!field4}}=<\$calc>{{!!field1}} + {{!!field2}} + {{!!field3}}</\$calc>
>> into field4.
>> What went wrong?
>>
>

--
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