How to solve this maths operation

Suppose I have 10 tiddler which are tagged with Account1 , each having a field called month with value say April, and another field called amount which has some numerical value.
Of this 10 tiddlers, 5 are tagged with income and 5 are tagged with expense.

In the tiddler titled Account1, I want to get the value of this mathematical operation

sum of the value in the amount field of tiddlers tagged with income and has month field as April minus sum of the value in the amount amount field of tiddlers tagged with expense and has month field as April

How to do it?

Something like (Assuming you are in tiddler Account1) :

<$list filter="[tag<currentTiddler>tag[income]month[April]get[amount]sum[]] [tag<currentTiddler>tag[expense]month[April]get[amount]sum[]negate[]]+[sum[]]"/>
2 Likes

Thank you. That works perfectly.
Is there any way to get the month and year into the filter from the created date instead of using a field like month and year

Perhaps

<$vars thismonth="[<currentTiddler>get[created]format:date[YYYY0MM]match[202204]]">
<$list filter="[tag<currentTiddler>tag[income]filter<thismonth>get[amount]sum[]] [tag<currentTiddler>tag[expense]filter<thismonth>get[amount]sum[]negate[]]+[sum[]]"/>

</$vars>
1 Like

This one doesn’t seem to work. Can it be due to the date format used?

I tested before I submitted, so it works for me. Remember that it has to be in a tiddler called “Account1” and that the target tiddlers need to have been created this month. If you started working on this project in March, then their created date might be from then, possibly?

Sorry it’s working. The problem occurred because of the error in the macro I created using that code. Thank you for the help.

1 Like