2 Replies Latest reply on Jun 10, 2020 9:28 AM by Tammy Ding

    How can I add two integer fields in smart reporting?

    Tammy Ding
      Share This:

      Thank you!

      Tammy

        • 1. Re: How can I add two integer fields in smart reporting?
          Sinisa Mikor

          If you wish to add values of two fields from one "record" (that usually means from the same row in report), either define calculated field to store sum as <first integer field> + <second integer field> and use it where needed, or make sure that both fields are used as report's column and apply advanced function Sum of Columns to column which you wish to replace with sum of those, with function's only argument (Column) set to first of those two columns (you could also use both fields as report's columns, but (either) one should be used twice to provide additional column which would have the same advanced function applied to it with column which was only added once as its argument to display both fields and their sum).

           

          If, however, you wish to add values of the same field from (two) different "records" (i. e. one value from row 2 and another value from row 3), you'll have to either somehow place both instances of that field in the same row (either by using append subquery, or by joining form (or joined forms) in report's view to itself) and apply one of methods suggested above, or use a different variant of latter method -- since Sum of Rows doesn't exist (there is Accumulative Total, but it accumulates values from all preceding rows instead of just neighboring ones), there are some additional steps to calculate this:

           

          1. There is only one field which should be used as one of report's columns; these values could be represented symbolically as a(n), where n is current row's index
          2. Add field from 1. as another column and apply advanced function Delta From Last to it -- this will calculate difference between value in current record and value in record preceding it (e. g. integer field from row #3 - integer field from row #2); these values could be represented symbolically as a(n) - a(n - 1)
          3. Add field from 1. as yet another column and apply advanced function Difference of Columns with column from 2. as its argument; these values could be represented symbolically as a(n) - [a(n) - a(n - 1)], or simply a(n - 1), which is value of field from previous row
          4. Finally, add field from 1. as yet another column and apply advanced function Sum of Columns with column from 3. as its argument; these values could be represented symbolically as a(n) + {a(n) - [a(n) - a(n - 1)]}, or simply a(n) + a(n - 1), which happens to be sum of value of field from 1. from current and preceding row

           

          In case you need to add value of one field from previous row (e. g. <first integer field>, or a) and a different field from current row (e. g. <second integer field>, or b), use <first integer field> as field being added as report's column in 1., 2., and 3. to retrieve its value, and  <second integer field> as field being added as report's column in 4. so that finally calculation would display a(n - 1) + b(n), in other words -- sum of <first integer field> from previous row and <second integer field> from current row.

           

          NOTE:  Unlike addition in calculated field, advanced functions can only be applied to columns, but any of those column can be hidden or left visible, as desired.

          4 of 4 people found this helpful
          • 2. Re: How can I add two integer fields in smart reporting?
            Tammy Ding

            Hi Simisa,

            This is very helpful! Thank you so much!

            Tammy