Click here to Skip to main content
11,718,016 members (83,490 online)
Click here to Skip to main content

Tagged as

How to display distinct data from a duplicated data source in an InfoPath form

, 20 Oct 2011 CPOL 12.3K
Rate this:
Please Sign up or sign in to vote.
How to display distinct data from a duplicated data source in an InfoPath form

Sometimes we have to get data to our InfoPath forms from various sources (From SQL Table, using a Web Service, from a SharePoint list, etc.).

But most of the time, it’s really annoying, if you do not have the option of filtering them directly from the backend (so all the duplicated data will be displayed).

For this example, I will be using the following SQL table with duplicated data:


So when I connect and retrieve data to an InfoPath form, I will get the following result. (I am using an InfoPath list box to display the data). And if you note, you can see various duplicated values are there in the list.


And I have used the following connection to retrieve data:


We can eliminate the duplicated values by applying the following filter to the list box. To do that, follow these steps:

  • Right click on the list box and select ‘List Box Properties’:


Click on the ‘Select XPath’ button in front of Entries field.


Click on the filter button on the next screen.


And add the following filter:

not(. = ../preceding::<XPath>)

<XPath>’ is the data source entry of your list box control. To find the XPath, right click that data field and select ‘Copy XPath’.

In my example, the XPath is:


But since I am referring to it from ‘/dfs:myFields/dfs:dataFields/’ branch, it should be omitted and only ‘d:temp_table/@Name’ is required.

So the filter should be:

not(. = ../preceding::d:temp_table/@Name)

Click ‘OK’ on all dialogs and close them. And when you preview your form, you can see only the distinct values.


Hope this will help you. Smile


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Manjuke Fernando
Technical Lead Air Liquide Industrial Services (Singapore)
Singapore Singapore
I have been in software industry for more than 8 years. I have developed different type of software using different languages. Many of them are database related (both web & window based), SQL being as the back end most of the time. Up-to-date I have knowledge in languages such as C#, VB.Net, T-SQL, JAVA, VB6 & C++, making C# the most proficient of all. Also I have worked using different technologies like ASP.Net, SharePoint, Crystal Reports (But I really hate designing reports) & MS SQL Server and have involved in designing & developing software for major companies like FedEx, Softlogic Holdings, IronOne Technologies & Brandix. Currently I am working as a Tech Lead in Singapore.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150901.1 | Last Updated 20 Oct 2011
Article Copyright 2011 by Manjuke Fernando
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid