Flag new values

Anyone up for a modeling challenge?

I have a solution but I’m interested if you have a better idea. I need to show only the unique values in a repeat in an expression. To achieve this, I want to model a single computation rule so that I can set a helper field to true each time a new value is added to the repeat.

Can you complete the computation rule?

Here are some 2024.06-ext5 models to start with.
RepeatFilterUnique_DM.json (3.5 KB)
RepeatFilterUnique_FM.json (5.4 KB)
The model structure comes from the real requirement being in a CDM context.

Feel free to look in the Solution but here are a few thoughts from my side if you are still working on the problem:

  1. We cannot create a Calculation Cycle. As a result we cannot just loop through the values of StringField. This means we need a helper field, HelperField.
  2. We have Language Constructs that can test if a value is not unique, FieldValuesNotUnique(FieldList) or RepetitionNotUnique(FieldList @From Group), but no Language construct to mark a value as unique.
  3. We can easily use FirstFilledValue(FieldList) to get the first value that meets certain conditions but as we learnt in 1. and 2., it’s hard to define when to return this value…

Let’s try and use this idea of “FirstFilled” to specify the requirement clearly.

The Requirement is:
Set the Value of HelperField to true when the value of StringField is the “FirstFilled” value.

alternatively…
Set the Value of HelperField to true when the value of StringField is not present in the ValueList of the indexes StringField less than the current index.

Solution
NoFieldValueIncludedInValueList(RepeatData/StringField In
        /RepeatFilterUnique*/RepeatData/StringField Having
          CurrentRepetition(/RepeatFilterUnique) < CurrentRepetition($/RepeatFilterUnique))
  1. NoFieldValueIncludedInValueList(FieldList IN ValueList) ensures that no Field value in FieldList is contained in ValueList
  2. CurrentRepetition(Group) allows us to find the index of the current row
  3. Having CurrentRepetition(/RepeatFilterUnique) < CurrentRepetition($/RepeatFilterUnique) restricts the ValueList /RepeatFilterUnique*/RepeatData/StringField to the indexes less than the current index. (The $ symbol points to the current row and this is compared to all other rows)