Counting Unchecked Checkboxes - InfoPath Dev
in

InfoPath Dev

Counting Unchecked Checkboxes

Last post 12-28-2012 08:27 AM by Jimmy. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 12-28-2012 05:52 AM

    Counting Unchecked Checkboxes

    I have several groups of checkboxes in different categories which are all checked by default.  The checkboxes are used to score or rate calls and if more than 4 points are deducted then the call is failed.  Some of the checkboxes are worth 2 points and others are worth 4 points.  I'm looking for a way to count the number of unchecked boxes and determine the value of them.  I was thinking of putting the total value of the unchecked boxes into a hidden field and if it is >=4 then the call is failed.

    My two questions are:

    How do I count the number of unchecked boxes and get their values?

    How do I put the total value into a hidden field (textbox)?

    Thanks 

  • 12-28-2012 06:09 AM In reply to

    Re: Counting Unchecked Checkboxes

    Could you show us a screenshot of what your data source looks like?
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-28-2012 06:23 AM In reply to

    Re: Counting Unchecked Checkboxes

    I hope this is what you need.  I'm using a Sharepoint 2010 list as a datasource. 

    This is a copy of my actual data entry form.  The circled box is the hidden field where I try and calculate the number of points deducted.  I put the Greeting section in a section just to experiment but I don't know if this makes a difference or not.  Thanks.

  • 12-28-2012 06:57 AM In reply to

    Re: Counting Unchecked Checkboxes

    I see. Well probably the simplest approach would change your checkboxes so that the checked value is 0 and the unchecked value is the point value of each particular question.  Then the way to calculate the number of points would be just:

    G_Name + G_Clear + ...

    You could use this in the default value formula of your hidden field.

    To count the number of unchecked boxes, you could use:

    count((G_Name + G_Clear + ...)[. != 0])

    You can simplify the formulas a bit by renaming the checkbox fields so they have a consistent naming pattern, (e.g. prefix all the field names with "Check_").  Then the formulas would become:

    sum(/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/*[starts-with(local-name(), "Check_")])

    count(/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/*[starts-with(local-name(), "Check_")][. != 0])

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-28-2012 07:28 AM In reply to

    Re: Counting Unchecked Checkboxes

    Thanks for the help.  I think I want to pursue option 1 and just set the unchecked value to the value of each question but how do I change these to 2 points?  The only options for checkboxes are 1/0 or True/False.
  • 12-28-2012 08:27 AM In reply to

    Re: Counting Unchecked Checkboxes

    Either approach would involve setting the unchecked values to the point values.  The second option just allows using a shorter formula.

    In order to allow values other than 1/0/true/false, the fields need to be a different datatype (either numeric or string). I'm not sure if field datatypes can be changed in list forms, but if not, you can probably delete and re-add them with the correct datatype, then create checkboxes from them.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.