Limiting the number of items to be selected

Dear community,
@Gassim greetings from Rwanda, I just wanted to ask a question about multiple select options, now that we know that multiple select is not implemented yet the way I am trying to implement it is to create different data elements with yes only and combine them in one section (this is your suggestion @Gassim thank you it is solving my implementation issue), however now I have the situation that I want your support as you always do,
is there a way we can limit the number of data element to be selected in a given set of data elements with YES Only value type?
ex: we have ten YES only data elements but in selection we don’t want a user to go beyond 5 selections



1 Like

Hi @Pacifique_Hategekima,
Thanks! I’m glad it worked. Sorry for keeping you waiting! :smiley: The immediate idea that came into my mind is to count the number of selections. Each time a data element is selected a value of one is added to a Data Element … when this value is greater than the number of allowed data elements, a program rule (or more) hides the data elements that don’t yet have a value.

expression: if data-element-1 has value OR data-element-2 OR …
action: add to data-element ‘count’ + 1

PR2 (an option):
expression: if count = ‘a number’
action: hide section

If hiding section is not the best option and you only want to hide the remaining data elements then maybe create several program rules:

expression: if data element ‘count’ = ‘a number’ AND data-element-x has no value.
action: hide data-element-x

and so on!

Hope this helps! :+1: Will let you know if I have an update. Thanks!

**update:**I predict an issue here, if they select then unselect! Please know I’ve not tried this myself!

Thank you @Gassim I think this can solve the issue, let me try it and the issue of unselect I’m thinking on letting the variable accept negative values then on select I add 1 on unselect I subtract 1, let me check if it can work, thank you


this also is creating an issue every time I open that event 1 is subtracted…

1 Like

@Gassim I think I am missing a post here that I thought is interesting, saw it in email, usage of program indicator, yes I can make program indicator that counts number of selection, the problem is how can I use it to limit the number of selections.


1 Like

@Pacifique_Hategekima Okay thanks! I deleted the post because I wasn’t able to quickly test it but here’s the idea.

  1. Program Indicator counts the number of selected data elements
  2. Program rule checks if Program Indicator > 5 (MAX number of selections)
  3. If MAX then continue the previous process:

** instead of count, use PI

  1. Another program rule that checks if program indicator < 5 then it unhides all data elements!

However, my thoughts are how are program rules (2 and 4) going to be triggered… (probably by the change in the program indicator value in 1?)

Thanks for your following up! (:

Hope this works @Pacifique_Hategekima :crossed_fingers::crossed_fingers::crossed_fingers::crossed_fingers:

@Gassim Thanks you, this can work I hope, however I wonder if we have an option of calling Program indicator in a program rule?


1 Like

You’re welcome! :slight_smile: So I was right when I deleted that post :laughing: Maybe we’ll have to stick to the first option ‘program rule’ and solve the issue when 1 is subtracted when you open the event! (:

:sweat_smile: I did quietly ask myself but didn’t invesitage … actually, I don’t think we can unfortunately, so maybe if you think this is a great idea to create a discussion in #implementation category and if other members think it’ll be helpful we could create a jira feature request and add our votes!

1 Like

true, let me continue digging on these suggestions because they are really on good directions, will revert if I find solution

1 Like