5 Replies Latest reply on Aug 26, 2014 2:33 AM by shae1725

    need help with a calculation (previous record)

    shae1725

      Title

      need help with a calculation (previous record)

      Post

           I need help on a calculation for table::total

           table::number  +  previous record table::total

            

           basic example

           Record        table::number         table::total

           1                         5                           5

           2                        10                         15

           3                        12                         27

            

           I have tried using a running total summary but it creates un desirable results as I add new records

            

           thanks

        • 1. Re: need help with a calculation (previous record)
          philmodjunk

               And what are those "undesirable results"? (Need to know that before we can suggest an alternative.)

          • 2. Re: need help with a calculation (previous record)
            shae1725

                 when I add a new record or delete a record  all the  table::total go blank until I click on the screen!

                 the field is used in other calculations and by a  javascript drawing on a canvas in a webviewer, so when the field blanks it creates an almighty mess.

                 I would also  like to avoid scripting it

            • 3. Re: need help with a calculation (previous record)
              shae1725

                   I worked it out, if any one knows of a better way or can see where issues with my calculation could arise please let me know

                    

                   thanks

              • 4. Re: need help with a calculation (previous record)
                philmodjunk

                     I would go with the summary fields, but script a commit records step to force an update of the summary field every time a new value is added. There's an upper limit to how many records you can have in your found set before you run out of system resources needed to compute a  value when you rely on getNthRecord like this. On an iOS device, you can reach this limit very quickly.

                     But a middle ground that may work is to use the above calculation in an auto-enter calculation to copy values from the preceding record. This creates update issues if you later delete a record, but avoids the limitation that I just mentioned.

                • 5. Re: need help with a calculation (previous record)
                  shae1725

                       Hi Phil

                       I compiled a script which triggers when creating a new record by going fetching the active portal number  and setting the value in table::total

                       The Script goes to the first portal number  total::total  and loops through to the last checking the fields value against the portal number and changing if necessary.

                       Same principle for removing records.

                       Works a treat but maybe that's because I only have a  maximum of 10 records in each sorted portal.

                       Not sure if I will ever need this function for anything with more records than I mentioned but would be interested what you think about using for larger tables

                       Thanks