How to create a reverse cascading select, I have a question with 50 options in Q1 and 10 options in Q2, and now i want to filter Q2 which is multi select based on the selection of the Q1. For eg, if in Q1 any of option 1 to 8 is selected then in Q2 option 1 will be shown and in Q1 any of option 9 to 18 is selected then in Q2 option 2 will be shown and so on… Hope the question is clear, thanks in advance as this is my first post in this forum.
Hi @khasaab,
Welcome to the community! Would you mind having a look at the post that has already been discussed earlier which should help you sort out the issue.
Hi,
I have checked the replies to your link send and it does not satisfy the need, its a normal choice filter where the choices for both the question are same, but in my case the scenario is different and the choices are also different. What i want is something like reverse cascading select where the previous questions has more choices and the next question which is dependent has fewer choices. For eg. if in Q1 one selects 1/2/3/4/5/6, then for Q2 option 1 should be visible, and if 7/,8/9/10 is selected then option 2 should be visible, similar to reverse cascading select. Have also gone through your reverse cascading faqs but it has something different to answer. Thanks in advance again.
Sorry for the bother but was waiting for the reply
This is actually just a regular cascading select - there isn’t such thing as a reverse cascading select (and the number of choices displayed doesnt actually matter…). Basically, the choice_filter defines an expression that each choice must pass in order to be displayed. That expression can be as arbitrary as you like: eg "if the user previously chose ‘Banana’ then only display choices beginning with ‘m’… "
Take a look at the XLSForm example, which may give you a better idea of how it all works; it ‘filters’ based on other attributes besides just simply the name, which may be what you are after.
Thanks for the reply. Sorry to say but it was not clear. I am unable to attach the Sample Form as the new users are not allowed to do, so just pasting the sample choices here .
list_name name label
brand_list 1 ASATAF
brand_list 2 APPLAUD
brand_list 3 CONTAF
brand_list 4 CONTAF PLUS
brand_list 5 BLITOX
brand_list 6 TAFGOR
brand_list 7 TATA MIDA
brand_list 8 MANIK
brand_list 9 ERGON
brand_list 10 TATA PANIDA
brand_list 11 TAKUMI
brand_list 12 TATA MONO
pest_companies 1 Rallis
pest_companies 2 Bayer
pest_companies 3 Syngenta
where for q1 there are 20 options as brand_list and q2 has 3 options as pest_companies. My requirement is if in q1 options any of 1 to 5 are selected then only option 1 i,.e Rallis of q2 to be visible , and so on. I am finding it difficult to write the choice_filter as for cascading select previous list is always smaller but in my case previous question list is bigger than the next question.here, can you please help me out. Sorry for the trouble.
OK. I see what you are getting at now, and why you are thinking ‘reverse cascading selecting’… But, again, all there is is a choice_filter that you can use to determine whether to show each choice or not. In your case, presumably you want to show the pest_company name in Q2 if one of their products was selected in Q1. There are a few different ways to do this, or varying complexity (ie messiness) but probably the simplest is by just re-labelling the name associated with each product so that the value contains a reference to the company. Specifically:
brand_list A1 ASATAF
brand_list A2 APPLAUD
brand_list A3 CONTAF
brand_list A4 CONTAF PLUS
brand_list A5 BLITOX
brand_list B1 TAFGOR
brand_list B2 TATA MIDA
brand_list B3 MANIK
brand_list C1 ERGON
brand_list C2 TATA PANIDA
brand_list C3 TAKUMI
brand_list C4 TATA MONO
and similarly
pest_companies A Rallis
pest_companies B Bayer
pest_companies C Syngenta
Then your choice_filter can just look for the presence of the company tag (ie name=A, B or C) in the list of selected brands to determine whether to show the associated company, using
choice_filter = contains(${brand},name)
where ${brand}
is the list of selected brands, ie your Q1
Here’s a form with all this. Load it into XLSForm Online and have a play around:
brands.xls (20.5 KB)
(I probably have the wrong brands associated with the 3 companies, but you get the idea)
This seems like what i was looking for. Although i have to change the name of the choices, but its fine as far its the only way to solve the problem. Will try this method thanks for the reply.
If you stick to the 1…20 labeling of brands then it makes the required choice_filter needed to identify the associated company significantly more complicated (more so because the brands are in a select-multi…). Basically you’d end up having to hardcode a very long condition for each company against each brand, which isn’t readily scalable if wanted to ever add more brands and their associated companies. Hence I recommend the above approach.
Thanks a ton.