Question
I want to be able to sum numeric data in the result of a search. Currently I could do so by creating a table and using the
SpreadSheetPlugin, however if I do not want to display the table then this becomes an issue. Normally I am using the
FormQueryPlugin and the SUMFIELD macro however since I am using the new Twiki release, then the SUMFIELD is just giving 0 in the sum. Is there another way to do this?
Environment
--
GustavoAdolfoLopez - 29 Mar 2005
Answer
I never used the
FormQueryPlugin, so without it:
You do not need to create a table to build a sum from a search result. Initialize a
SpreadSheetPlugin variable before the search, then in the
format="" sum it up. Simulated and untested example, assuming topics with
TWikiForms containing a formfield named Count:
%CALC{$SET(sum, 0)}%
%SEARCH{ "something" format="$percntCALC{$SETM(sum, +$formfield(Count))}$percnt" }%
Result: %CALC{$GET(sum)}%
Alternatively, put the search into HTML comments, output a table, and use the spreadsheet
$SUM($ABOVE()).
--
PeterThoeny - 30 Mar 2005
Gustavo, if you can use Peter's solution, do so.
If you can't, then if can you give me some clues, like what version of
FormQueryPlugin,
DBCachePlugin, and TWiki you are using, and where the field comes from (relation, form, embedded table) I might be able to help.
--
CrawfordCurrie - 30 Mar 2005
I am having a similar problem : have a twiki3 in production using
FormQueryPlugin and FORMQUERY and MATCHCOUNT. The 4.0.2 sources for this plugin show that MATCHCOUNT has been removed and
DBCachePlugin information makes no reference to summing the results as far as I can tell.
So we do need a way to bring back this feature from 3.0 to 4.0.2.
IMHO, not being able to do Search with operators like AND, OR or precedence with () is a major drawback with the %SEARCH.
Since there isn't any activity on this front, I am assuming that I'll have to plunge into the source and rool a fork of the
FormQueryPlugin or the
DBCacheContrib internaly.
Any one else interested in this or is the usage of
FormQueryPlugin all that low in the wild ?
--
JoseVenceslau - 30 May 2006
--
JoseVenceslau - 30 May 2006
Possibly better to post this in the
FormQueryPluginDev topic.
--
PeterThoeny - 30 May 2006