I want to log various activities during the day and I was planning to use a field for each activity.
Let’s say the ‘run’ field is for duration of runs. I know I can sum the total time across tiddlers with this:
{{{ [tag[log]get[run]sum[]] }}}
But let’s say I go for 2 x 30 minute runs. Rather than entering 60 minutes for the day’s total, is there a format that would allow 30 & 30 to be entered in the same field to give the total but also showing the 2 events?
Ah, thanks Mat - I thought there was probably a way of doing it.
I just meant that the 2 entries would show that there had been 2 events.
At first your solution didn’t sum the contents of the fields from the other tiddlers until I found out that a space was required after the number entered into the field - without the space, the number wasn’t summed - if that makes sense.
I meant if some of the tiddlers only had a single entry eg. ‘5’, then that number wouldn’t be added with the others, unless a space was inserted after it - try it!
Last thing, how would I get the average instead of the sum? (tried replacing the word but doesn’t work)
Jon - here you are relying on split[ ] to divide entries but perhaps you should be using listops and enlist functionality instead.
Though personally this idea of multiple time entries (times in one field) is little additional information. I would encourage you to create a tiddler for each logged time, you can then provide start and end times, where you went, notes etc… or the intermediate a “data tiddler”. Tiddlers such as time log entries can otherwise be hidden. This would allow you to add more features as you proceed.
Well, that’s odd. I’ll try it on TW tomorrow but in my wiki, if I have 2 tiddlers with the number 5 & 10 in each respective field, without a space after the number, the total shows as zero and only shows 15 with the space after the digit.
Thanks Tones and I am generally getting into the better habit of using smaller units and not lumping things together, but in this case, I don’t need that level of detail - although I will give it some thought, just in case.
Regards
Jon
So, I upgraded my wiki expecting the same, but not so:
Split sum and count behave as they did before - the space after the number is required. So if there are 2 tiddlers with a single number in the field for each tiddler, split sum and count are zero unless there is a space after the number.
The average calculation is now recognised in my wiki (before there was no output) but it doesn’t include the total from multiple entries in a single field.
I’ve uploaded something here to show the calculations working as expected and with the screenshots from my wiki showing the difference there.
Presumably there must be something in my wiki which is responsible for the different behaviour - would be good to know what.
Well I don’t really know why, but I thought that if it works when you add space, then the filter can add space by itself with join[ ].
I tested it in your online example and it didn’t break the working example, so why not!
Adapting your suggestion worked for the average as well but what’s weird is that the original average calculation also started working!! (the split sum remains unchanged)
I thought I’d seen this during testing but ignored it as there were too many variables to deal with, so there is definitely something intermittent at work with regard to the average calculation at least.
I’m pleased I’ve got something to work with now, but it would be good to know if there’s something lurking in my wiki which I need to exorcise!