Help with a calculation

Hi,

A: {{{ [tag[test]get[f1]join[ ]split[ ]sum[]] }}}

B: {{{ [tag[test]count[]] }}}

How do I get A divided by B?

I’ve played around with it but no luck

Thanks
Jon

https://tiddlywiki.com/#divide%20Operator%20(Examples)

You can combine both filters like this :

{{{
[tag[test]count[]]
:reduce[[tag[test]get[f1]join[ ]split[ ]sum[]divide<currentTiddler>] 
}}}

Thanks telumire, but that seems to produce zero.

I’ve put it up on here

Regards
Jon

Thanks, that’s what I’d played around with without any luck.

This works:

<$vars a={{{ [tag[test]get[f1]enlist-input:raw[]] +[sum[]] }}}>
<$vars b={{{ [tag[test]count[]] }}}>
answer={{{ [<a>divide<b>] }}}

Notes

  • enlist-input:raw turns field contents (from f1 fields) into separate values and keeps duplicate values

enjoy,
-e

Brilliant!
Thanks again Eric!

Just a quick one Eric!

Where do I put this ‘divide[60]fixed[2]]’ or similar, to divide answer by 60 and round to 2 places?
(I’ve tried various combinations)

Thanks again
Jon

Got it at last!

<$vars a={{{ [tag[test]get[f1]enlist-input:raw[]] +[sum[]] }}}>
<$vars b={{{ [tag[test]count[]] }}}>
answer={{{[<a>divide<b>divide[60]fixed[2]]}}}

Thanks again
Jon

Sorry about that, here’s the working solution :

{{{
[tag[test]count[]]
:reduce[all[tiddlers]tag[test]get[f1]join[ ]split[ ]sum[]divide<currentTiddler>] 
}}}

or alternatively

{{{
[tag[test]count[]]
:reduce[[test]tagging[]get[f1]join[ ]split[ ]sum[]divide<currentTiddler>] 
}}}

I forgot that to “reset” the filter run in a :reduce run, you need to add “all[tiddlers]” at the start of the run or use the “tagging[]” operator, otherwise it tries to find your tagged tiddlers in the last result (which here is a number, so it wont find anything and return 0).

No problem!

And many thanks for the alternative solution which I’ll squirrel away for future use!

Regards
Jon