Comments on Calc Macro

Last modified by Joao Peixe on 2023/04/06 10:07

  • GeoffreyKing
    GeoffreyKing, 2011/02/26 13:55

    v1.0 - The sum macro appears to treat negative numbers as positive when summing.

    • Jie Pan
      Jie Pan, 2018/03/19 01:43

      Add the following code to line 138 of Macros.CalcGroovy page will solve this problem.
      137         else {
      138           def value = 0;
      139
      140            Added by [email protected]
      141           
      deal with nagative numbers
      142           def prev = child2.getPreviousSibling();
      143           if (prev && prev.toString().equals("-"))
      144             content = "-" + content;
      145
      146           try {
      147            value = Float.parseFloat(content)
      148             println "ADDING: ${value} for content ${content}"

  • Roman Muntyanu
    Roman Muntyanu, 2012/01/13 02:42

    I experience >100% CPU usage and page loads 20 seconds on following use-case

    |=Event date |= Description |=People Involved |=Rate ?/person |=Comments |=Total budget |= Granted
    |2012-02 |Team building in the mountains|29|400|Including mobility team|(% style="text-align: right;" %){{calc formula="$C*$D" format="0"/}}|
    |2012-03|Release pizza party|17|30|Pizza party for finishing maintenance release|(% style="text-align: right;" %){{calc formula="$C*$D" format="0"/}}|
    |2012-06|Release pizza party|17|30|Pizza party for finishing release in scope of half/year collaboration|(% style="text-align: right;" %){{calc formula="$C*$D" format="0"/}}|
    |2012-07|Team building in the mountains|29|400|Final release team building |(% style="text-align: right;" %){{calc formula="$C*$D" format="0"/}}|
    | | | | |(% style="text-align: right;" %)**Grand total**|(% style="text-align: right;" %)**{{sum type="col" format="0 ?"/}}**| 
  • Charlie M
    Charlie M, 2015/02/17 00:45

    The Calc Macro worked well in xWiki 6.3.  After upgrading to 6.4.1, the macro stopped working and now displays: "Failed to execute the [groovy] macro. Click on this message for details."

    Debugging the CalcGroovy script, it appears that when the script does a .getParent() on the MacroBlock that is coming in, it is returning null.  Previously, it used to return the TableHeader block of the table containing the Macro. 

    Are there any workarounds for this issue, or plans to make it compatible with 6.4.x?

    Thanks

  • Ludovic Dubost
    Ludovic Dubost, 2015/02/18 09:40

    I'll try to look at it and see what I can do

  • Ludovic Dubost
    Ludovic Dubost, 2015/02/18 14:50

    Yes I confirm what Vincent is saying. It should work again after the core issue is fixed.

  • Fabrizio Lungo
    Fabrizio Lungo, 2016/07/25 17:31

    The {{sum /}} macro needs a way of filtering rows. I would suggest a parameter of "exclude" which takes a comma separated list of rows to exclude. My current issue is that the row headings also have a number in them and then this gets added to the sum.

  • Joao Peixe
    Joao Peixe, 2023/04/06 10:07

    I've encountered an unexpected result with the calc formula. When I try to get values either by using $b or $col.get(2), if the value is 20, I get 2020. So instead of sum, let's say, 20+10, the sum is 2020+1010=3030. Am i doing something wrong? In the same table, sum is working fine.

Get Connected