Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Suggested Answer
+1
person also asked this
people also asked this
Replies
14 replies
Answers
2 answers
Subscribers
10 subscribers
Views
20873 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are t
fariaj
over 10 years ago
I have an Array {1,2,3,4,4,5,3} . I want to know how many duplicate values are there in that Array and the output should return the unique duplicate values like {3,4}. Is there a function to gets this output?
OriginalPostID-144331
OriginalPostID-144331
Discussion posts and replies are publicly visible
Top Replies
Thenmozhi Mohanakrishnan
over 7 years ago
+2
Certified Senior Developer
load( local!a: {1,2,3,4,4,5,3}, remove(local!a,a!forEach( items: union(local!a,local!a), expression: wherecontains(fv!item,local!a)[1] )) )
Josh
over 6 years ago
in reply to
davel001150
+2
Certified Lead Developer
It is not correct based on the example provided in the original question. I'm glad it helped you out, though.
Josh
over 6 years ago
in reply to
Mike Schmitt
+1
Certified Lead Developer
See you in 18 months for another thread revival.
Parents
0
darbyk
Certified Lead Developer
over 10 years ago
Hi Fariaj, if I understand your use case, you want to find and return the duplicate items in your array (e.g. findDuplicates({1,2,3,4,4,5,3, 3}) will return {3,4}. This is a quick way to do it I believe (keep in mind you'll probably need some null checks):
TEST_isDuplicate:
=length(wherecontains(ri!value, ri!array)) > 1
Then the actual rule - TEST_findDuplicates:
=with(
local!input: {1,2,3,4,4,5,3},
local!uniqueInputs: union(local!input, local!input),
filter(rule!TEST_isDuplicate(_, local!input), local!uniqueInputs)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
darbyk
Certified Lead Developer
over 10 years ago
Hi Fariaj, if I understand your use case, you want to find and return the duplicate items in your array (e.g. findDuplicates({1,2,3,4,4,5,3, 3}) will return {3,4}. This is a quick way to do it I believe (keep in mind you'll probably need some null checks):
TEST_isDuplicate:
=length(wherecontains(ri!value, ri!array)) > 1
Then the actual rule - TEST_findDuplicates:
=with(
local!input: {1,2,3,4,4,5,3},
local!uniqueInputs: union(local!input, local!input),
filter(rule!TEST_isDuplicate(_, local!input), local!uniqueInputs)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data