Skip to Content
avatar image
Former Member

Compare values of different contexts and return true/false

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jul 06, 2017 at 07:38 AM

    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

    Add comment
    10|10000 characters needed characters exceeded