Ignore previous post - I figured it out - RTFM.
I am looking for an answer to this question -- could you post the solution you found?
Our donations table lists gifts in a portal that sorts by date in ascending. I am creating a basic Thank You letter which should pull the donation amount of the most recent gift. When I insert the field as a merge field in the letter layout, it pulls the first donation listed (which is the oldest donation). But I want it to pull the most recent donation.
Even when I tried sorting the portal in descending order by date (so that the most recent entry appears on line 1) it still pulls the first date.
I'm sure there is a step I am missing, I just can't figure out what it is! Please share what you learned with the solution you found here...
Thank you! ~ shaun
Either sort the relationship (not just the portal) by date ascending, or use the Last() function.
Ah, yes! I see. So I would actually need to create a new field called Last Gift Amount or something, and calculate that to pull the last gift. Correct?
If you're using the Last() function, yes. If you sort the relationship in the opposite order, you can use the related data directly (a reference to a related field gets the data from the first related record, in the sort order of the relationship).
BTW, if you don't want to change the sort order of the relationship, you could also enclose the relevant paragraph (or even the entire letter) in a one-row portal, and sort that portal by date descending. That way you wouldn't need to add any calculation fields.
OK. So I created a new field with a calculated result of Last(gift_amount).
Sorted the relationship by gift amount descending.
And it works! Thanks so much for your quick and super helpful responses. ~ shaun
Just in case anyone else needs this:
The calculation should be:
Last ( Donations::gift_amount )
and the relationship should be sorted by date, not amount (otherwise you'll get the largest donation instead of the latest one).