2 Replies Latest reply on May 13, 2012 8:22 AM by PeterMcnamee

    total fields to variable



      total fields to variable


      I have a numerical field called 'days'.

      I would like to total or sum all values in the field 'days' to a variable.

      Is this possible?


        • 1. Re: total fields to variable

          I'm assuming that 'all values in the field' mean that you have multiple records and you want the total of this field across all the records in either your table or a found set...

          Define a summary field as the "total of" your days field.

          Perform a find to bring up the set of records for which you want this total or do Show All Records if you want the total for all records.

          A script step can then use: Set variable [$Total ; value: Yourtable::Summaryfield ]

          to copy the value into a variable.

          There are other ways that use either a looping script or a relationship to compute the same total. And if you have multiple values in a single field or in repetitions of a single field, that can be done as well.

          • 2. Re: total fields to variable

            Thanks Phil.


            I'll try this.


            The script I've written, loops, performing a find, based on a unique identifier. It is then supposed to count the number of occurances of the identifer, total the number of days for all records showing the unique identifier. The srcript then creates a new record in a separate table and inserts the unique identifier, the number of occurances and the total number of days. It does insert the identifer, number of occurances but always gets the total wrong.


            I've tried it and it does work. The reason it did not total correctly into the summary field previously is because I had not sorted on the unique identifier.