Skip to Content
0

Compare values of different contexts and return true/false

Jul 06, 2017 at 06:18 AM

21

avatar image

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

capture.jpg (43.2 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Avinash Bandela Jul 06, 2017 at 07:38 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks a lot for your prompt help Avinash. This works perfectly fine.

Best regards,

Aman

1