Hi Eric, Thank you!
Emily On Monday, July 27, 2020 at 10:01:59 AM UTC-7 Eric Shulman wrote: > On Monday, July 27, 2020 at 7:40:30 AM UTC-7, [email protected] wrote: >> >> 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. >> > > While Evan's FormulaPlugin is very useful (and ground-breaking at the > time), as of TiddlyWiki v5.1.20, the TWCore has math operators built-in as > filters. > https://tiddlywiki.com/#Mathematics%20Operators > > Here's how you might use these built-in operators instead of the > FormulaPlugin... > > For this example, I created a tiddler named "FoodLog" containing the > following: > Choose a month: > <$select field="month"> > <$list filter="January February March April May June July August > September October November December" variable="month"> > <option><<month>></option> > </$list> > </$select> > > <$vars > bad={{{ [tag[FoodLog]tag{!!month}tag[bad]count[]multiply[-1]] }}} > decent={{{ [tag[FoodLog]tag{!!month}tag[decent]count[]multiply[1]] }}} > good={{{ [tag[FoodLog]tag{!!month}tag[good]count[]multiply[2]] }}} > entries={{{ [tag[FoodLog]tag{!!month}count[]] }}}> > > There are <<entries>> items in {{!!month}}, > with an overall feeling score = > <$text text={{{ > [<bad>add<decent>add<good>divide<entries>multiply[1000]trunc[]divide[1000]] > }}}/> > > Good:<br> > <$list filter="[tag[FoodLog]tag{!!month}tag[good]sort[]]" > ><li><<currentTiddler>></li></$list> > Decent:<br> > <$list > filter="[tag[FoodLog]tag{!!month}tag[decent]sort[]]"><li><<currentTiddler>></li></$list> > Bad:<br> > <$list filter="[tag[FoodLog]tag{!!month}tag[bad]sort[]]" > ><li><<currentTiddler>></li></$list> > > Then, I created some test tiddlers with appropriate tags: > "Hotdogs" tags="FoodLog, July, good" > "Ice Cream" tags="FoodLog, July, good" > "Jello" tags="FoodLog, July, decent > "Potato Salad" tags="FoodLog, July, bad" > "Watermelon" tags="FoodLog, July, good" > > The output shown in FoodLog, is: > >> >> *Choose a month: July * > > > > >> *There are 5 items in July, with an overall feeling score = 1.2* > > > > *Good:* >> >> - *Hotdogs* >> - *Ice Cream* >> - *Watermelon* >> >> *Decent:* >> >> - *Jello* >> >> *Bad:* >> >> - *Potato Salad* >> >> > Notes: > * $select gives you a droplist of month names. The selection is stored in > FoodLog, in the "month" field. > * $vars calculates the "bad", "decent", "good", and "entries" values for > the selected month, using the weighted value system you described in your > post. > * The output shows the number of entries for the selected month, followed > by the calculated "feeling score" > * The feeling score is "the average of their weighted values" as you > described in your post, which I rounded to 3 decimal places. > * Following this result are bullet lists showing the individual food > entries, sorted alphabetically, grouped by "good", "decent", and "bad" > > enjoy, > -e > > -- 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/f5740493-06b8-4bcf-983c-e51189d511e7n%40googlegroups.com.

