Filter the data that is displayed in a control

When you design a Microsoft InfoPath 2010 form template, you can use filters to limit lists of choices to a designated subset that users can select from when they fill out a form. Filters can also be used to display a subset of data from a data source, which reduces the number of available records in a control.

In this article

Overview

Set a filter for a list box, drop-down list box, or combo box

Set a filter for a repeating section or table

Unexpected filter results

Overview

Use a filter whenever you need to, based on defined criteria, display a subset of the data that is returned by a query. Criteria can be an item that is selected in another control (such as a list box, combo box, drop-down list box, or text box) that is bound to a field in the data source. For example, if you are creating a form template that is used to track products from several suppliers, you can choose to display all products from all suppliers, or add a filter that enables users to select a supplier, and then only display products from that supplier. If the user then selects another supplier, the list is updated with the products from the other supplier.

Tip:  If you know that your users require a consistent subset of a query result, modify your query to return only this subset instead of using a query to retrieve all the data and then applying a filter to create a subset. This improves how quickly the form loads because the query returns only the required data from the external source.

Top of Page

Set a filter for a list box, drop-down list box, or combo box

To configure a filter on a list box requires a list box, drop-down list box, or combo box control in the form template that is populated from a column of tabular data. You cannot filter data that has been manually entered into a control using the Control Properties dialog box.

  1. Select the control that you want to filter.

  2. Under Control Tools, on the Properties tab, in the Properties group, click Control Properties.

Filter the data that is displayed in a control

  1. Do one of the following:

    • To use values from fields in the form, click Get choices from fields in this form.

    • To use values from a data connection, click Get choices from an external data source, and then select the desired data source that you want to use.

      Filter the data that is displayed in a control

  2. Next to the Entries box, click Select XPath Filter the data that is displayed in a control .

  3. Select the field or group that contains the desired values for the control, and then click Filter Data.

Filter the data that is displayed in a control

  1. Click Add.

Filter the data that is displayed in a control

Note:  If you want to add a condition to an existing filter, click the filter that you want, and then click Modify.

  1. In the first box on the Specify Filter Conditions dialog box, click the name of the field whose data you want to filter.

Filter the data that is displayed in a control

  1. In the second box, click the type of filter that you want to use.

  2. In the third box, click the type of condition that you want to apply to the filter, and then type the condition. In the previous example, the contents of the control are filtered so that the contents of the Category field are equal to the contents of the category field in the data source.

  3. If you want to specify additional criteria for the filter, click And, and then specify the desired criteria. When you do this, a fourth box appears. Click a modifier, click and if both conditions should be applied to the filter, or click or if either condition should be applied to the filter.

Top of Page

Set a filter for a repeating section or table

To configure a filter on a repeating section or table, a list box, drop-down list box, or combo box control is required in the form template that is populated from a column of tabular data in the form’s main data source. An external secondary data source cannot be used when filtering a repeating section or table.

  1. Select the repeating section or table that you want to filter.

  2. Under Control Tools, on the Properties tab, in the Properties group, click Control Properties.

  3. Click the Display tab.

  4. Click Filter Data.

Filter the data that is displayed in a control

  1. Click Add.

Note:  If you want to add a condition to an existing filter, click the filter that you want, and then click Modify.

  1. In the first box on the Specify Filter Conditions dialog box, click the name of the field whose data you want to filter.

Filter the data that is displayed in a control

  1. In the second box, click the type of filter that you want to use.

  2. In the third box, click the type of condition that you want to apply to the filter, and then type the condition. In the previous example, the contents of the control are being filtered to where the contents of the Category field in the form are equal to the contents of the category field from the data source.

  3. If you want you want to specify additional criteria for the filter, click And, and then specify the desired criteria. When you do this, a fourth box appears. Click a modifier, click and if both conditions should be applied to the filter, or click or if either condition should be applied to the filter.

Top of Page

Unexpected filter results

When testing the form, if the values in the control that contains a filter are not correct because there are either too many or not enough values, try the following:

  • If using multiple conditions in the filter, remove all but one condition to check that the correct values are returned from that single condition. If the first condition returns the correct values, add another condition, and test again. Continue to add each additional condition until the issue is found.

  • If the filtered values are exactly opposite of what is expected, such as if the products from all of the suppliers display instead of the products from a single supplier, then change the filter type in the condition. For example, if the condition uses the filter type is equal to and too many products are returned, try using the filter type is not equal to.

Top of Pages

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×