Is there a way (a function perhaps) to eliminate duplicates within a repeating list, for example, so that duplicates would not be repeated twice but only once when used in the table?
There is a @distinct special function that does exactly what you want (= takes a list and returns a new list without any duplicates), but you cannot currently use this function on the datafield that causes a table row to repeat.
We are thinking about constructing tables dynamically through a new special function. In the meantime, the best workaround is to use repeating bullets in a @for loop:
@for(?X, @distinct(#alpha^delta), @BULLET)
BULLET =
* Item ?X
OK, I get this example.
@for(?X, @distinct(#assistant^head-of-practice), ?X)
To complicate the matters, how would I then place it within @in-language?
@in-language(#assistant^head-of-practice, "en")
I’m afraid this is currently not possible. Due to the way @in-language is constructed, it expects datafield, but the @distinct function converts the datafield passed to it into a regular list.
I added a feature request for filtering the repeating list: Allow repeating rows in a table to be filtered
Thank you. Looking forward for this feature.
In the workaround mentioned above, is there a way to get rid of the bullet symbol (leaving a simple line)?
Hi Tomas,
I have just implemented a solution to the feature you requested. It will show up on the various ClauseBase servers late this weekend, after some further testing.
You can now write the following:
|| #alpha^beta || {not(@get(@is-duplicate(#alpha^_beta), @index))}
- @is-duplicate special function returns a list of true/false values for each of the list-items passed to it, with true meaning that that item is a duplicate of some previous item in that list. So, for example, @is-duplicate(“aaa”, “bbb”, “ccc”, aaa") would return a list containing elements false, false, false, true
- the weird underscore after the circonflex means “use the repeating list as a whole, instead of the single item in it at this current instance of the repeated row” (see the bottom of https://help.clausebase.com/kb/repeating-list-datafields/ for more info)
- so the entire condition between { … } means “show this row if the nth element in the list returned by @is-duplicate is false”, i.e. “show this row if the nth element is a previously unseen element”
- not shown in the example, but this also works with @in-language(#alpha^beta) in a cell of a row that is effectively shown
Works nicely. Thank you!