locked
Count unique items in a SharePoint 2013 List using an Infopath Form RRS feed

  • Question

  • I have built a tracking form to look at a list, count the number of complete learning modules then post that number within the form which is hosted on a Team Site. It functions as a real time dashboard to give a user their number of completed modules. The InfoPath form has various formulas on Form Load to query the list and count the items. This all works fine but I was seeing that users that take the same course multiple times are included in the count. I cant set the list to no duplicates allowed yet because I am mid training cycle. I would like to manipulate the COUNT function to only count unique training certificates per user so:

    I currently use this:

    count(xdXDocument:GetDOM("Certificates")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Title)

    Simple but it doesn't return unique values, so I tried to modify a piece I found from searching (a lot of searching):

    count(xdXDocument:GetDOM("Certificates")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Title[not(@-->xdXDocument:GetDOM<--("Certificates")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Module = preceding-sibling::dfs:Title/@xdXDocument:GetDOM("Certificates")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Module)])

    However that returns a "Node-error expected" the indicators points to this area of the syntax:

    d:Title)[not(@-->xdXDocument:GetDOM<--("Certificates") 

    Any ideas or more efficient ways to find a user and only count those unique modules are greatly appreciated.



    • Edited by GEE OTTO Monday, March 7, 2016 7:22 PM
    Monday, March 7, 2016 7:13 PM

Answers

  • hi,

    i have found your another thread with the same question in InfoPath forum:

    http://www.infopathdev.com/forums/t/31025.aspx

    seams you have followed Hilary's suggestion:

    count(xdXDocument:GetDOM("Certificates")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[d:Title != preceding-sibling::d:SharePointListItem_RW/d:Title])

    and it works.

    congratulations.

    Monday, March 14, 2016 12:46 PM

All replies

  • Hi,

    Here you go

    http://sp365.co.uk/2012/05/count-list-items-in-infopath/


    Please remember to click &#39;Mark as Answer&#39; on the answer if it helps you

    Monday, March 7, 2016 9:07 PM
  • Hi Gee Otto,

    The “@” in XPath is used to get attributes of the elements. “xdXDocument:GetDOM(‘<DataSourceName>’)” is used to get the data source.

    Please remove “@” from “…[not(@xdXDocument:GetDOM("Certificates")…”. Use “…[not(xdXDocument:GetDOM("Certificates")…”.

    Best regards,

    Linda Zhang


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Tuesday, March 8, 2016 7:33 AM
  • I already do that now I need to go one step further, hence the unique value question. Thank you for your suggestions that is actually a very simple and easy thread to follow to create a count form. :)

    Tuesday, March 8, 2016 4:10 PM
  • Thank you for that advice I removed the "@" but I still got the node error. Let me provide some more details on the issue. I want to only count the unique [Module] for each [Title] where [name] represent a  sharepoint column. Should I be using [Module] for the exclusion syntax?

    I inserted the [Module] for the exclusion portion of the formula and got the following result:

    count(xdXDocument:GetDOM("Certificates")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Title[not(xdXDocument:GetDOM("Certificates")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Module = preceding-sibling::dfs:Module/-->xdXDocument:GetDOM<--("Certificates")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Module)])

    Thank you for you help thus far!

    Tuesday, March 8, 2016 4:22 PM
  • better representation of the count formula used:

    count(Title[not(Title = preceding-sibling::Module)])

    Tuesday, March 8, 2016 7:34 PM
  • hi,

    i have found your another thread with the same question in InfoPath forum:

    http://www.infopathdev.com/forums/t/31025.aspx

    seams you have followed Hilary's suggestion:

    count(xdXDocument:GetDOM("Certificates")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[d:Title != preceding-sibling::d:SharePointListItem_RW/d:Title])

    and it works.

    congratulations.

    Monday, March 14, 2016 12:46 PM