I have a repeatable group with 2-n elements. I want to extract the last element using a computation rule. I can select the first element using FirstFilledValue, but there is no such expression for the last element.
I am effectively looking for a LastFilledValue function.
I tried getting the last index by using NumberOfFilledFields, however I don’t know how to access an element at a specific index either.
Hi @patrick-long-drift
You just need to use FirstFilledValue(FieldList) with a filter. You can find out the Index of an instance of a repeatable Group using CurrentRepetition(Group).
It ends up looking like this:
FirstFilledValue(MyRepeat*/RepeatValue Having CurrentRepetition(MyRepeat) == NumberOfFilledGroups(MyRepeat*))
based on
LastRepeatIndex_DM.json (3.5 KB)
(The precondition is not necessary but it fitted your description of 2-n elements so nicely that I couldn’t resist)
FYI We also have a Monthly Modeling Highlight video on “Indexing in Repeats” from October 2023. This is still quite up-to-date as the Kernel Language is very stable.
These videos are available for mgm’ies and partners through the respecitve e-learning platform.