# Custom Logic for Multiple choices

Hello, I am building a form where we have multiple choices and follow-up questions from the multi choices. For example, A farmer plants Maize, Beans and let us say fruits. I would like the interviewer to select all three products and not be able to skip the follow-up questions from the choices, for example, How many kgs of maize does the farmer harvest? How many Kgs of Beans…etc. the problem is, Once I write a mandatory custom logic formula for like
'How many kgs of maize does the farmer harvest? ’ —> \${Product} = “Maize”
'How many kgs of beans does the farmer harvest? ’ —> \${Product} = “Beans”

Once the interviewer selects all three products, S/he can skip the questions. Kindly assist

Hi @cotrrafrica and welcome to the community!

Can you share a screenshot with us? Where do you write the formula, what is your formula and the screenshot of this issue:

1 Like

I replicated the same formula changing from maize to bean to the next question and Fruits to the next.
When I select just one product, i.e Maize, the mandatory custom logic works, but when I select multiple products, i.e maize, and beans, the custom logic does not work at all

The next image

@cotrrafrica Can you click on the Settings on the question “What do you mainly plant in your Farm?” so we can see the `data column name`?

1 Like

@cotrrafrica Thank you for the screenshots.

Let’s talk about the logic behind it.

When you say `\$(QUESTION) = "ANSWER"` the XLS form understands as:
`"use this logic when ONLY the ANSWER is given"`
so when someone picks 2 choices, in your case Maize and Beans, the answer is not ONLY the Maize or ONLY the beans, it is both of them
This is important because in `select_one` questions this approach works, but in `select_many` questions it doesn’t.

So there comes the `selected(\${QUESTION}, 'ANSWER')` approach. In this logic, you are basically saying “use this logic when the ANSWER is selected” (notice there is no ONLY requirement in this way)

Long story short, changing the custom logic to `selected(\${plant}, "maize")` should work as you want.

Feel free to ask if you have more questions

1 Like

Thank you so much. Problem solved.

2 Likes