Tags:
create new tag
view all tags

SID-00066: How to calc average in form

Status: Answered Answered TWiki version: 4.1.2 Perl version: 5.8.8
Category: CategoryForms Server OS: Ubuntu 8.04 Last update: 17 years ago

Hi,

Im not sure if this is possible but what I am trying to do is create a TwikiForm with the final row that calculates an average of the results above.

I've tried variations of

$percntCALC{"$AVERAGE($ABOVE())"}$pernt 
$percntCALC{"$AVERAGE(R1:C2..R$ROW(+1):C2)"}$pernt 
%CALC{"$AVERAGE(R1:C2..R$ROW(+1):C2)"}%
%CALC{"$AVERAGE($ABOVE())"}%

in the values field with label and text types but always gets 0.

Thanks

-- BrinleyAng - 30 Jan 2009

Discussion and Answer

If you want to do some SpreadSheetPlugin calculation within a FormattedSearch SEARCH format you need to escape the CALC. You do not need to escape the CALC if you add a footer row after the SEARCH.

Here is a silly example that shows the age in hours between create date and last update date of the latest 10 question pages, and a footer row that calculates the average of the days:

Question Age
Restoring a parent-less web from Trash 5
Regex search: lookaheads 688
'rcs too old' even though it's version 5.10.0 32335
Is MailInContrib Installed On TwikiDotOrg 32
viewfile timeout 7
TWiki causes an error when accessed through VPN 14
Supported OS for TWiki-6.1.0 24
Registration without personal data (like e-mail adress) 328
Manage link seems to be incorrectly retrieved 10
Locked down Main web blocks user Watchlist topic creation 0
Average hours: 3344

Do a "Raw View" to see the source.

-- PeterThoeny - 30 Jan 2009

How do I implement this with a TwikiForm? As in have a form as follows

|*Name*  |*Type*  |*Size*  |*Values*  |*Tooltip message*  |*Attributes*  |
| QuestionOne | text | 40 | | | |
| QuestionTwo | text | 40 | | | |
| QuestionThree | text | 40 | | | |
| AVERAGE | text | 40 | $percntCALC{"$AVERAGE($ABOVE)"}$pernt |||

Such that when I create a new page, I can add the above TwikiForm, fill in the numeric values of QuestionOne, QuestionTwo and QuestionThree and get the average calculated after saving those values?

-- BrinleyAng - 10 Feb 2009

In the template page where you have the form attached add this text to the AVERAGE field:

%CALC{$AVERAGE(%FORMFIELD{QuestionOne}%, %FORMFIELD{QuestionTwo}%, %FORMFIELD{QuestionThree}%)}%

-- PeterThoeny - 10 Feb 2009

      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 How to calc average in form
SupportCategory CategoryForms
TWiki version 4.1.2
Server OS Ubuntu 8.04
Web server Apache 2.2.8
Perl version 5.8.8
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2009-02-10 - 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.