We help IT Professionals succeed at work.

How do I Count the Number of Selections in a Multi Select List?

-Polak asked
I'm trying to use a combination of rules, default values, and the count() function to count how many selections a user makes from a multi select list populated from a SharePoint Data Connection. I've tried to follow this thread:

It's not working for me. I can only get the behavior to correctly count how many have been selected after one that was selected is DE-selected.

How do I accomplish this?
Watch Question

Clay FoxDirector of Business Integration
I have never been able to use a multiselect successfully.  I would use a secondary data connection and a repeating table to have them select that way. I have found that to be much easier.


Okay, even though there are 50 possible selections in the multi-select, and a user may need up to 25, I can live with going with that solution...

So now that I have a repeating table (with 3 columns) how do I count how many selections a user makes? I realize that I can count the repeating group and only place 1 field in each group; however, with up to 25 selections being made that will make my form unnecessarily long....

I've tried (in the default value of my count field):
Count(/my:myFields/my:Capability/my:MissionPartRT/my:ReqCapMissPartners/[my:testing1 = "XYZ"]

But this only counts if the user selects XYZ in  the first column/field.... what I really need is an expression that allows me to say count testing1 <> "..." + testing2 <> "..." + testing3 <>"..."
("..." being the hypothetical default value in each of the repeating fields).
However, it appears that "<>" isn't the right expression for "does not equal".

Also/Separately, kindly see my question on promoting data from repeating groups to SharePoint... basically I'm asking if there's anyway to create unique fields on SharePoint from a repeating group or if its best to just use a delimiter and handle separating the data on the analysis side....
Clay FoxDirector of Business Integration
You may want to add a Boolean field to your list of selections, just to make that easier.
You could then put a rule on that check box field that does a concatenation or an addition to create what you describe.  The only issue there is if they uncheck and recheck etc.  The logic to weed that out gets a bit hairy.  Not sure if you just need a count of selections or you want a list of the selections they have made.

Ultimately you want to be careful of hardcoding certain values because inevitably someone comes along and want to change a value.

Hope that helps.
Okay I think I follow you... see the image to illustrate:
Here's what I did:


Entered  "..." as default values in testing1 and testing2


Created a rule that set bootest1 = "true" if testing1 <> "..." AND a rule that set bootest2 = "true" if testing2 <> "..."


went on sharepoint and added "..." as a possible Value for selection so that if a user needed to "go back" and not identify a Mission Partner they had an available selection that matched the default value.


Created a rule that set bootest1 = "false" if testing1 = "..." AND a rule that set bootest2 = "false" if testing2 = "..."


Set the default value of the mission owners count field equal to:
count(/my:myFields/my:Capability/my:MissionPartRT/my:ReqCapMissPartners[my:bootest1 = "true"]) + count(/my:myFields/my:Capability/my:MissionPartRT/my:ReqCapMissPartners[my:bootest2 = "true"])
That seems to cover the solution... did I understand you correctly?
Clay FoxDirector of Business Integration

Sure that should work.


My solution is identified as the best solution as it should  should help other novice users better understand and provides a walkthrough; but, I wouldn't have gotten there without clayfox's recommendations.