Count the instances of a field

Microsoft Office InfoPath

Show All Show All

Count the instances of a field

You can use expression boxes to count the instances of a field and perform other calculations. When you create formulas in an expression box, you refer to the fields and groups to which controls on the form are bound, rather than the controls themselves. The formulas are created using XPath, but you can follow these steps without knowing XPath.

  1. In design mode, place the insertion point where you want to insert the expression box.
  2. If the Controls task pane is not visible, click More Controls on the Insert menu.
  3. In the Controls task pane, click Expression Box.
  4. Enter an expression such as the following in the XPath box in the Insert Expression Box dialog box:

    count(my:group1/my:group2/my:field3)

    Note  In this expression, my:group1/my:group2/my:field3 is only an example. When you type your count expression, you must replace the example with an XPath expression that identifies your specific field.

    ShowHow?

  5. To test the formula, click Preview Form on the Standard toolbar.