4 Replies Latest reply on Sep 11, 2015 12:55 PM by tays01s

    Calculating a record from >1 other record

    tays01s

      I have 2 tables: Calc > Eqs.

      Eqs: Has several fields and records containing text equations.

      Calc: Has the same fields and number of records.

      A script populates Calc records by setting each field to Evaluate(Eqs::field).

       

      However, in 2 cases, it would be much easier to calculate a particular record from values in a previous record. How would you do this?

        • 1. Re: Calculating a record from >1 other record
          erolst

          tays01s wrote:

          I have 2 tables: Calc > Eqs.

          Eqs: Has several fields and records containing text equations.

          Calc: Has the same fields and number of records.

          A script populates Calc records by setting each field to Evaluate(Eqs::field).

           

          What's the point of doing this? Can you give an example?

           

          tays01s wrote:

          However, in 2 cases, it would be much easier to calculate a particular record from values in a previous record. How would you do this?

           

          Which cases are these, and what does “previous” mean in that context?

          • 2. Re: Calculating a record from >1 other record
            tays01s

            Say Field1's record 5 required values from record 2 and 3, how would I refer to records 2 and 3? I realise I could simply use a combination of the calcs used to get records 2 and 3, but they are v. long strings, so I'd rather avoid this.

            • 3. Re: Calculating a record from >1 other record
              erolst

              That's not a particularly enlightening answer … therefore, I can only give you two generic answers:


              Record 5 needs something from record 2 and 3 because …


              1. … there is something that connects them, i.e. they have something in common (e.g. they are paragraphs in a chapter?). If that is so, encode that common thing into a field, use it for a self-join and use something to give these records a position.


              Finally, sort the relationship by that position, and you can use GetNthRecord() to read a field value from a specific record, or GetValue() to parse a value out of a list of field values of all related records.

               

              2. … these records are part of a process that brings them together in a found set; their position then is their record number, and you can use GetNthRecord().

              • 4. Re: Calculating a record from >1 other record
                tays01s

                On first trialling, this appears to do the job brilliantly; I'm now trying to apply it several more places in the solution.