Enabling conditions from roster in previous section

Dear all,

I am getting troubles to write and enabling condition in my survey.

The case is as follows. I have a crop roster in which I ask the respondent to state whether he/she sell part of the production for each type of crop he/she cultivate in a plot, included in the roster, as the picture below

In a following section of the survey I want to ask to whom the respondent sells the crop production. I want to enable this question only if at least for one crop, in the crop roster, the respondent answered “yes”, that he/she used to sell the crop production.
I wrote the following enabling condition that should count how many times the answer is a yes, and enable the question only if the count is positive.

(crop_roster.Count(x=>x.sell_harvest_crop==1))>0

but i get the warning message “the name crop_roster does not exist in the current context”.

Could you please advise me on this?

@DavideBellucci , this can happen if the crop_roster is nested in some other roster, like parcels, for example. Then at the household level it is not clear what crop_roster you mean, the one from parcel 1? or one from parcel 2? etc.

Or a simpler case, that there is perhaps a typo in crop_roster.

If neither of the above is the case, then please show how crop_roster is defined, since it is not obvious from your message.

Thanks for your reply @sergiy.

Yes, my crop_roster is a nested roster into a land_plot roster (like land parcels). Indeed, as you are pointing out, each household might manage different land parcels, and in each parcels there might be more than one single type of crop cultivated.
Actually in my enabling condition I want to refer to any crop type in any land parcels. That is, if for any crop in any parcel the respondent answered at least in one case to sell the crop production, then the question should be asked.

Thanks

The most intuitive would be to introduce an intermediate variable SOLD “something is being sold from this parcel” [Boolean] with the expression that you’ve shown.

Then your target variable will be something like:

(parcels.Any(x=>x.SOLD==true))

Using Any() instead of Count() should make it work faster, since you only need the fact not the exact count (would probably be noticeable if you had like a hundred of parcels/crops).

Thanks @sergiy!

Your explaination have been very useful. I managed to solve in the way you suggested. Just created a variable in land_plot roster right after the crop_roster and used it in my enabling condition using your expression!

Best,
Davide