Hello all,
I have a scenario where I need to compare values of different contexts and then return a true/false accordingly.
As can be seen in attached image, values of context 1,2,5 and 6 are equal and values of context 3 and 4 are equal. I need a logic that will return a true for the first occurrence of each unique value and a false for re-occurring value. So, for the queue shown in image, i need the output as:
True
-Context Change-
False
-Context Change-
True
-Context Change-
False
-Context Change-
False
-Context Change-
False
If comparing different contexts is an issue, I will not use SplitByValue (as used in the attached image) and can compare all the values of the same context. SplitByValue can then
be used later. In such a case, following is the output that I am expecting:
True
False
True
False
False
False
Looking forward to your kind inputs.
Best regards,
Aman
Hi Aman,
Use SplitByValue later and try following UDF code with All values in queue.
String str[]=new String[input.length]; int index=0; String s=""; for(int i=0;i<input.length;i++) { s="true"; if(i==0) { str[index]=input[0]; index++; } else { for(int j=0;j<str.length;j++) { if(input[i].equals(str[j])) { s="false"; break; } } if(s.equals("true")) { str[index]=input[i]; index++; } } result.addValue(s); }
Thanks,
Avinash B
Thanks a lot for your prompt help Avinash. This works perfectly fine.
Best regards,
Aman