Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
8 replies
Subscribers
9 subscribers
Views
9098 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Is there a straight forward way to compare the list of values on an array. I ha
hayleyw
over 11 years ago
Is there a straight forward way to compare the list of values on an array. I have currently tried
pv!arrayA=pv!arrayB and len(pv!array!=pv!arrayB) but both equations return a True if the just the FIRST item has been returned. I need to ensure that all items have been found and that they are an exact match.
Many thanks...
OriginalPostID-77307
OriginalPostID-77307
Discussion posts and replies are publicly visible
0
evan.rust
Appian Employee
over 11 years ago
Hi Hayley, would exact(pv!arrayA,pv!arrayB) work?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Dan
over 11 years ago
You should be able to use set functions to accomplish this. If you take the intersection of the 2 arrays, every item that appears in both array will be returned. If the length of each of the arrays is equal to the length of the intersection of the two arrays then the arrays must be equal. Also note, len() is for getting the length of a text value, length() will return the size of an array.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
revat.anandsongkit
Appian Employee
over 11 years ago
intersection() is definitely a valid approach. Few questions though..Does order matter? Do you care about duplicates? i.e. if pv!array1 = {1,2,3,4} and pv!array2 = {4,2,2,3,1}, should that return true or false?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
hayleyw
over 11 years ago
Thank you for the replies. In answer to your questions, the order doesn't matter and neither do duplicates. I just need to make sure that for each value in arrayA there is a also a value in arrayB
Thanks
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
joel
over 11 years ago
I use =if(length(difference(ri!array1,ri!array2))>0,true,false) for doing this. It doesnt matter about the order or duplicates and we use to match two CDT's as part of a dual entry process which works very well/
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
hayleyw
over 11 years ago
Hi Joel
Thank you for your response, with a slight amendment to make it fit your formula has resolved me.
Thanks everyone for your help.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
revat.anandsongkit
Appian Employee
over 11 years ago
@Joe - difference() works but I would make three suggestions to your rule. 1) Get rid of the if() condition. Having just the condition will already return a Boolean. 2) It should be >= . 3) Consider the edge case that array1 and/or array2 are null. Modified rule -->length(difference(ri!array1, ri!array2))>0
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Sathya Srinivasan
Appian Employee
over 11 years ago
Hayley, Set functions are the best bet in your case. Depending on what you want as an outcome (simply a Boolean or the difference in the record), you might want to use difference() as per Rikhi's recommendation,
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel