I've reached a somewhat clunky solution, although I'm not sure why it works:
\define bad() (= value([tag[Food Log]tag[July]tag[bad]count[]]) =) \end <$wikify name=badNum text=<<bad>>> (= value(<<badNum>>) * 2 =) </$wikify> Emily On Monday, July 27, 2020 at 7:40:30 AM UTC-7 [email protected] wrote: > Hi Evan, > > I've just discovered Formulas and I'm enjoying its straightforward > crunching. Thank you so much for making this awesome plugin! I'd like to > make a tiddler that shows the overall "feeling score" of a food logging > database by counting the number of results for each mood (bad, decent, > good). Then, I'd find the average of their weighted values: (bad * -1 + > decent * 1 + good * 2) / totalEntries. > > I'm stuck on converting the number of results for the filter into a > number. > > \define bad() > (= value([tag[Food Log]tag[July]tag[bad]count[]]) =) > \end > > (= <<bad>> * 2 =) > > returns: > > ComputeError: Cannot convert "2" to number! > > Yet (= value("2") * 2 =) returns 4 as expected. I suspected that the > mushrooms (?) may have been redundant when defining <<bad>>, but removing > them lead to another error. > > Thanks, > > Emily > > > On Tuesday, January 16, 2018 at 11:15:24 PM UTC-8 [email protected] > wrote: > >> Announcing the second generation of my formula plugin for TiddlyWiki. >> >> See the *Formula wiki* for the latest documentation: >> http://evanbalster.com/tiddlywiki/formulas.html >> >> *Report issues and view source GitHub*: >> https://github.com/EvanBalster/TiddlyWikiFormula >> >> >> Formula lets you do computation in TiddlyWiki in the style of popular >> spreadsheet apps Excel and Google Sheets, with the addition of TiddlyWiki's >> own filter, transclude and variable systems. Tiddlers can behave like >> individual rows in a spreadsheet. A large collection of built-in functions >> is included, for use with text, numbers, dates, arrays and regular >> expressions. >> >> Formula is implemented as a widget, with a special *(=* "mushroom >> bracket" *=)* syntax for inclusion in WikiText, and can also be used in >> widget/HTML attributes. Formulas included via transclusion, filters and >> variables are computed and refreshed like any other part of your wiki. >> >> (= ( sum([tag[Profits]get[value]]) - sum(tag[Expenses]get[value]]) ) * {{ >> Tax!!rate}} =) >> >> The second generation of formula adds support for local variables, >> comments, lambda functions and element-wise operations on arrays (such as >> filter results), allowing more advanced computations to be expressed inside >> TiddlyWiki. Search the wiki for "demo" to see some of the things I've >> built. >> >> >> The plugin is a work in progress and may have bugs. Please report these >> on GitHub or in this thread. >> > -- 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 to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/1cf70f91-da36-46e8-b8cb-52f732821bd9n%40googlegroups.com.

