Skip to main content
New Participant
Jul 16, 2024 12:00 PM UTC
Question

How can I extract values with duplicate criteriaCode? (Remove one item and leave other)

local!combinedCriteriaResults: a!flatten(
    {
      local!test1.criteriaResults,
      local!test2.criteriaResults,
      local!test3.criteriaResults,
      local!test4.criteriaResults
    }
  ),

Local variables show there is two items with the same criteriaCode. How can I remove one item and leave the other with the same code?

5 replies

venkatrea696188
Inspiring
Jul 16, 2024 12:06 PM UTC

You can use union()  Function, but can you tell me more about requirement .

a!localVariables(
  local!test1:{1,2,3,4},
  local!test2:{1,2,3,4,5,6},
  local!combined:a!flatten({local!test1,local!test2}),
  union(local!combined,local!combined)
)

New Participant
Jul 16, 2024 12:20 PM UTC

The requirement is to remove one of the duplicate items from the local!combinedCriteriaResults

stefanhelzle0001
Brainy
Jul 16, 2024 1:30 PM UTC

Using union() and count() you can detect any duplicates. Then, for each item in the union, you can just pick a single item from the list. displayvalue() comes to my mind.

Question is, how do you decide which item to pick?