3 Replies Latest reply on Feb 4, 2013 10:14 AM by philmodjunk

    Portal Calculation Keeps Referring to First Record For Calculation Instead of Current

    Anthony_1

      Title

      Portal Calculation Keeps Referring to First Record For Calculation Instead of Current

      Post

           Hello All,

           First off I have been using Filemaker for a while but I am totally NEW to programming side of it.  I started using it heavily for my Dungeons and Dragons gaming session 2 years where I have created a character sheet template.  With the advent of  my Filemaker 12 upgrade I started learning how to use portals.  One of the portals I have created is based on spells that gives the user information on the spells they are using. In this portal there are two calculations: Calculated Spell Range in Feet and Calculated Duration in Rounds.  These calculations are supposed to  draw upon the users current "Caster Level".  The two fields in the spell portal are in a separate table from the "Caster Level".  An example of this is that it takes the "Caster Level" from one table and multiplies it by the "Spell's Range" from another.   (The tables all have relationships set up between them btw.)

           Here is the where the glitch occurs that I, being new, have no idea why it is acting this way.

           It will do the calculation correctly for the first record but after that if any new records are created the calculation in the portal of the new record always refers back to the "Caster Level" of the first record or is not seeing the "Caster Level" of the current record it is on so that range and duration are always being calculated from the first record's "Caster Level"

           How can I fix this glitch so that the calcuation in the portal will draw from the "Caster Level" of the current record?

           Thank you for any help and saving me from the mutiny of players feeling that they are stuck on Level 1

            

           Anthony

        • 1. Re: Portal Calculation Keeps Referring to First Record For Calculation Instead of Current
          philmodjunk

               Your calculations are doing exactly what you designed them to do. It's just not what you want them to do.

               WIthout having a detailed description of the tables and their relationships, I can't give you the detailed explanation, but can only provide a generalized response:

               If you have a one to many relationship:

               TableA----<TableB

               TableA::__pkTableAID = TableB::_fkTableAID

               Any Calculation in TableA that refers to a field in TableB evaluates independently of the current state of your layout. The presence or absence of a portal, what record in a portal row is currently "active" as no impact on how it evaluates. It will refer to the "first" related record in TableB. The "first" record in table B will be the related record in Table B that was created first unless you specify a sort order as part of the relationship. If you specify the sort order, whichever record sorts out to the beginning of the sorted list of related records is "first".

               There are two general solutions to this that make sure that the calculation references the correct record in TableB other than playing games with the sort order:

               1) Define a new relationship that is one to one, In other words in this new relationship a given record in TableA only matches to one record in TableB. This can be done using a new Table Occurrence for table B should the current one to many relationship be one that you need.

               2) Merge your two tables into one table so that the fields referenced by your calculation are now part of the same record as that which defines the calculaiton.

          • 2. Re: Portal Calculation Keeps Referring to First Record For Calculation Instead of Current
            Anthony_1

                 Thank you Phil,

                 I did find a way to make the calculation in the portal refer to the correct record.  I will apologize in advance for any response that lacks any degree of technical languare but I will do my best.

                  

                 Originally the calculation in the portal on any record was going back to the field in the first record.  Through some digging around and consulting with a friend we found that in the relationships window we set the criteria for the field to be sorted based on field used in the calculation in decending order.  This forced that portal to use the latest record for its calculation and was a simple fix.


                 I also like your answers as well.  Again thank you for the quick response and I am sure I will always have more quesitons.

                 Anthony

            • 3. Re: Portal Calculation Keeps Referring to First Record For Calculation Instead of Current
              philmodjunk

                   What you are doing is consistent with what I posted:

                   

                        The presence or absence of a portal, what record in a portal row is currently "active" as no impact on how it evaluates. It will refer to the "first" related record in TableB. The "first" record in table B will be the related record in Table B that was created first unless you specify a sort order as part of the relationship. If you specify the sort order, whichever record sorts out to the beginning of the sorted list of related records is "first".