Comparing string variables within a roster

I have a roster with multiple rows and two variables code and value. I want to ensure that distinct codes are entered against different rows. This validation rule should not check with blank entries
Please help me with the code.

From the description it looks to me like a job for the .Any() function, see here:

Regards, Sergiy

I wanted that all the items in the list should be distinct; no repition.

Dear Nilanjana,

the code will depend on the structure of your questionnaire of which you provide no details. Your first message mentions specifically “roster” , while the second message mentions specifically “list”.

Assuming that you have a list of crop codes for a plot the following check will make sure there are no duplicates:


which you will write for the categorical CropCode question.

  1. this may or may not work for your particular questionnaire. I am making a guess here.
  2. you are taking the responsibility for excluding duplicates. in many cases (including the crops) duplicates ARE justified.
  3. don’t use it for requesting the interviewers to NUMBER something , e.g. households in the listing. Hope you are not doing this.

Best, Sergiy

Following code worked:
roster1.GroupBy(x => x.prod1).Any(g => g.Count() > 1)==false