We help IT Professionals succeed at work.

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

-Polak
-Polak asked
on
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:
http://www.infopathdev.com/forums/t/13563.aspx 

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?
Comment
Watch Question

Clay FoxDirector of Business Integration
Commented:
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.

Author

Commented:
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....
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/InfoPath/Q_28625225.html
Clay FoxDirector of Business Integration
Commented:
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.
Commented:
Okay I think I follow you... see the image to illustrate:
Here's what I did:
snip

1.

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

2.

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

3.

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.

4.

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

5.

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

Commented:
Sure that should work.

Author

Commented:
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.