SID-00066: How to calc average in form
| Status: |
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:
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
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.