When list box entries are looked up in either the form's data source or a data connection, you might end up with the user being presented duplicate options. You can correct this, and display only unique options in a list, by using a filter and the appropriate XPath.
In this task we will create a filtered drop-down list box that presents the user with a unique set of options. Let's start by designing a new blank form.
Add the controls to the view:
- Open the Controls task pane.
- Insert a Drop-Down List Box into the view.
- Insert a 1 column Repeating Table into the view.
- Type Source Values into the header row of the repeating table.
Populate the drop-down list box:
- Double-click the drop-down list box.
- On the Data tab of the Drop-Down List Box Properties dialog box, select Look Up Values In The Form's Data Source.
- Click the Select XPath button to the right of the Entries text box, and then select group1/group2/field2.
Filter for unique values:
- Click Filter Data, and then click Add.
- In the Specify Filter Conditions dialog box, select The Expression from the first drop-down list, and then type the following expression (as shown in Figure 1):
not(. = ../preceding::my:group2/my:field2) |

Figure 1. Filtering list options to display only unique values.
- Click OK four times.
Try it:
Preview the form. Add several rows of values to the repeating table, making sure that some of the values are duplicates, and then examine the options in the drop-down list. As shown in Figure 2, the drop-down list only displays unique values as the XPath expression prevented duplicate values from being added to the list.

Figure 2. The filtered list box displays only unique options.
InfoPath applies our filter as it steps through the values in repeating table to add them to the list box entries. The XPath expression in our filter checks to see whether a my:field2 value in a previous row (my:group2) is identical to the my:field2 value in the current row. If it is, the value is not added to the list.
©2005 Greg Collins. All rights reserved. Licensed to Autonomy Systems, LLC for display on InfoPathDev.com.