Tags:
create new tag
view all tags

SID-00263: Using a QUERY SEARCH inside a CALC

Status: Answered 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.

Application Hours Name Date
Email 5 Bob 4/1/2009
Email 1 Bob 4/1/2009
Email 3 Bob 4/1/2009

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

      Change status to:
ALERT! 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.
SupportForm
Status Answered
Title Using a QUERY SEARCH inside a CALC
SupportCategory CategorySearch
TWiki version 4.2.1
Server OS Linux 2.6.18-53.el5 (i686-linux)
Web server Apache 2.2.10
Perl version 5.8.8
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2009-04-13 - BobMellinger
 
  • 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.