SID-00263: Using a QUERY SEARCH inside a CALC
| Status: |
Answered |
TWiki version: |
4.2.1 |
Perl version: |
5.8.8 |
| Category: |
CategorySearch |
Server OS: |
Linux 2.6.18-53.el5 (i686-linux) |
Last update: |
16 years ago |
How can I use a QUERY SEARCH within a CALC to get the MAXimum value of the results of the QUERY SEARCH?
Let's say the following represents the data contained in TimeSheet Forms.
And the following search is executed:
%CALC{ $MAX( %SEARCH{ " TimeSheetForm.Application = 'Email' " type="query" nosearch="on" nototal="on" format="$formfield(Hours)," }% ) }%
The result that is displayed is literally:
%CALC{ $MAX( 3, 1, 5, ) }%
The result that should be displayed is:
5
If I escape out the inside SEARCH,
%CALC{ $MAX( $percntSEARCH{ \" TimeSheetForm.Application = \'Email\' \" type=\"query\" nosearch=\"on\" nototal=\"on\" format=\"$dollarformfield(Hours),\" }$percnt ) }%
I get no results. What am I overlooking?
--
BobMellinger - 2009-04-12
Discussion and Answer
Your first search is almost correct, you want SEARCH to run first, then CALC. In your case, CALC fails because it expects the formula to be on one line. A SEARCH introduces newlines by default. To fix, use a
separator parameter, as in:
format="$formfield(Hours)" separator=", ".
--
PeterThoeny - 2009-04-12
That did it. Thanks very much !!!
--
BobMellinger - 2009-04-13
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.