Tags:
create new tag
view all tags

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

TWiki version: TWikiRelease02Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: RH
Web server: Apache 3.00
Perl version: 5.8.3
Client OS: Ms Windows 2000
Web Browser: Explorer
Categories: Forms

-- 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

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2006-05-30 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.