2 Replies Latest reply on Apr 10, 2015 1:44 PM by cosmocanuck

    "Last" function seemingly not working

    cosmocanuck

      Title

      "Last" function seemingly not working

      Post

      Hi guys! I’m having some trouble with the “Last” function.

       

      For a charity, I have a Donors table, and a related Donations table. On Donors is a field called “LastDonationDate”. It’s set as a calculation field with a value of

       

           Last(Donations::Date Received)

       

      But I’ve realized that it has ceased to update.

       

      Why would this be? I clearly am doing something wrong, but I’ve racked my brain and am at a loss.

       

      Thanks!

      adam

        • 1. Re: "Last" function seemingly not working
          philmodjunk

          a) Make sure that this is really a calculation field and not a date field with an auto-enter calculation. The auto-enter calculation would fail to update as data in the related records change.

          b) make sure that the "last" related record is the record you think that it is. Which record is returned as "last" here depends on the sort order options specified in the underlying relationship. To check/change the specified sort order, you go to Manage | Database | Relationships and double click the relevant relationship line to open a dialog where you will find an option for sorting the relationship. If you have never specified a sort order, this is an unsorted relationship and the Last record should be the most recently created record out of those that are related to your current layout record. A quick way to check this is to add an unsorted, unfiltered portal to donations to your layout. The very last portal row will then show data from the same record as your last function provided that the date field is not empty.

          c) be careful of "context". A given table can have more than one Tutorial: What are Table Occurrences? box in Manage | Database | relationships and each can be linked in a different relationship to the table occurrence specified as the "context" inside specify calculation when you set up this calculation. There's a drop down at the top of the dialog to use to select different occurrences of the table in which you defined this calculation field. So you have to make sure that you are using the correct relationship as controlled by what table occurrence you name inside that Last function (the text to the left of ::) and what table occurrence you select from the "context" menu.

          • 2. Re: "Last" function seemingly not working
            cosmocanuck

            Thanks so much Phil. It is now fixed. Most of this I had (in some fashion) considered, I thought - but now it does seem to be working fine. At minimum it's a good reminder of the various  issues that can come into play!