Tags:
create new tag
view all tags

SID-01439: Result of sum is showing dates?

Status: Answered Answered TWiki version: 5.1.1 Perl version:
Category: SpreadSheetPlugin Server OS: ubuntu Last update: 14 years ago

Hi! I'm wondering if might be doing something wrong the result of a sum is showing the date (year) of the formfield value.

%SEARCH{"[SWO]{3}-[0-9]{5};\bCategoryInvoice\b" type="regex" nonoise="on" nototal="on" excludetopic="*Template,TaskDB,*Task" web="DB" scope="text" separator="," format="|$percntIF{\" '$percntCALC{$FORMATTIME($TIME($formfield(Invoice date)), $year-$month)}$percnt' = '$percntSERVERTIME{$year-$mo}$percnt' \" then=\"$percntGET{\"$topictotal\"}$percnt\" else=\"0\"}$percnt|"}%
| %CALC{$SUM($ABOVE())}% |

result:

0
2012

showing the "year" of the formfield value instead of 0 in the last row.

-- MichaelSevero - 2012-03-28

Discussion and Answer

Just a quick reply without reading the details: You might run into an evaluation order issue. The CALC is not handled in the normal inside-out/left-to-right variable evaluation order, it is evaluated later. If you want to run the IF after CALC you need to embed the escaped IF in the CALC, such as %CALC{$NOP(%)IF{...}$NOP(%)}%.

-- PeterThoeny - 2012-03-28

Awesome!!

Thanks Peter for clearing it. What I did was use the "if" function of the CALC instead of the regular "IF statement"

My revision:

%SEARCH{"[SWO]{3}-[0-9]{5};\bCategoryInvoice\b" type="regex" nonoise="on" nototal="on" excludetopic="*Template,TaskDB,*Task" web="DB" scope="text" separator=","
format="|$percntCALC{$IF($FORMATTIME($TIME($formfield(Invoice date)), $year$month) == $percntSERVERTIME{$year$mo}$percnt, $percntGET{\"$topictotal\"}$percnt, 0)}$percnt|"}%
|%CALC{$SETM(swosalestotal, + $SUM($ABOVE()))}%|

again, thank you

-- MichaelSevero - 2012-03-28

I am glad it worked out. And thanks for reporting back for others to learn.

-- PeterThoeny - 2012-03-29

      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 Result of sum is showing dates?
SupportCategory SpreadSheetPlugin
TWiki version 5.1.1
Server OS ubuntu
Web server apache
Perl version

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2012-03-29 - 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.