Count multiple values in repeating table - InfoPath Dev
in

InfoPath Dev

Count multiple values in repeating table

Last post 05-18-2012 10:39 AM by rdrnnr. 23 replies.
Page 1 of 2 (24 items) 1 2 Next >
Sort Posts: Previous Next
  • 07-15-2011 02:13 AM

    • Laura
    • Top 500 Contributor
    • Joined on 08-27-2009
    • Posts 27

    Count multiple values in repeating table

    Hi, I am trying to do what I thought was a simple task, but is not working for me.  I have a repeating section with a repeating table and have programmatically set filtering to display only rows having a response of "Pass", and now I need to count multiple values within that table, such as # of apples, oranges, lemons.  I tried what I thought was a logical count function but I have a default of 2 and then it counts all rows in table then multiplies by 2!? Also, the # of values I need to count is 50.

     count(Ann_Item["AFFF/FFFP - gas cart./cyl"]) + count(Ann_Item["AFFF/FFFP - gas cart./cyl (B)"])

    Any suggestions would be really helpful

     

  • 07-18-2011 08:48 AM In reply to

    Re: Count multiple values in repeating table

    Hi -

    I'm having a little trouble understanding.

    But it sounds like you want to count items in your table based on more than one filter? That is, you want to count everything where a certain field = "pass" and another field = "AFFF/FFFP - gas cart./cyl"

    Can you attach your form template to a reply? Under the Options tab there is a place to attach a file...

    Hilary Stoupa

  • 08-03-2011 01:08 PM In reply to

    Re: Count multiple values in repeating table

     I am trying to find an answer to this issue.  I need to count the number of occurrences of based on two values.

     The data source I'm using is this:

    + Training_Form (repeating table)

       - Class_Select

       - Enrollment_Status

     

    My initial count was based only off the Class_Select variable: count(@Class_Select[.="XXXX-XX-XX"]).  I need to incorporate the Enrollment_Status variable as well.  For example, I need to count the number of rows where Class_Select AND Enrollment_Status are specific values.  I'm not even certain how the syntax should look.  In my mind, it's maybe something like: count(@Class_Select[.="XXXX-XX-XX"] && @Enrollment_Status[.="Enrolled"])

     

    Thanks for any suggestions,

    Eric

  • 08-03-2011 01:31 PM In reply to

    Re: Count multiple values in repeating table

     I wound up figuring it out: (@Class_Select[. = Class_Select and @Enrollment_Status = "Enrolled"])

  • 09-07-2011 06:45 AM In reply to

    • Laura
    • Top 500 Contributor
    • Joined on 08-27-2009
    • Posts 27

    Re: Count multiple values in repeating table

    As an update; I ended up having to use managed code.

    I appreciate your efforts at looking into this.

  • 09-07-2011 07:04 AM In reply to

    Re: Count multiple values in repeating table

    Not sure why this thread sent out a notification e-mail all of a sudden, but since you popped in...

    Your original post was very confusing, and you never responded to Hilary's request for clarification, but there is little doubt in my mind that this could have been resolved (and quite easily) without the use of managed code.

     If you're ever interested in replacing your code with built-in InfoPath functionality, we'll be here.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-22-2012 04:40 AM In reply to

    • Laura
    • Top 500 Contributor
    • Joined on 08-27-2009
    • Posts 27

    Re: Count multiple values in repeating table

    Thanks. I agree having to write code was a pain.  I am in a similiar situation, with another form, so let me try to be clearer.

    I have a node (../../OptGroup_EQUIPMENT/EQUIPMENT) and under that is 2 child nodes (../../OptGroup_EQUIPMENT/EQUIPMENT/equipmenttype; ../../OptGroup_EQUIPMENT/EQUIPMENT/EquipInsp)

    each of the child node have different list options, and I need to be able to count each equipment type, such as (Ladder), and of those Ladders I need to count (Fail).  I have tried AND to link the 2 conditions but it is not working.

    count (../../OptGroup_EQUIPMENT/EQUIPMENT/equipmenttype[. = "Ladder" and ../../OptGroup_EQUIPMENT/EQUIPMENT/EquipInsp = 'Fail'])

    Any help would be appreciated. 

     

  • 03-22-2012 03:05 PM In reply to

    Re: Count multiple values in repeating table

    I think it might be more like:

    count (../../OptGroup_EQUIPMENT/EQUIPMENT/equipmenttype[. = "Ladder" and EquipInsp = 'Fail'])

    You can attach a screenshot of your main data source under the Options tab - that can help us with the XPath if needed.

    Hilary Stoupa

  • 03-23-2012 05:19 AM In reply to

    • Laura
    • Top 500 Contributor
    • Joined on 08-27-2009
    • Posts 27

    Re: Count multiple values in repeating table

    Thanks for the response.  If I put the expression in the Text Box Properties/Default Value box I get an error that the value is not valid for my data type (which is Whole Number since it is count expression).

    If I use the fx  box I get the error ""../../OptGroup_EQUIPMENT/EQUIPMENT/equipmenttype/EquipInsp" does not point to a valid location path of a field or group."

    I am attaching a screenshot of my data source. 


  • 03-23-2012 08:00 AM In reply to

    Re: Count multiple values in repeating table

    What field are you setting the default value on?

    Hilary Stoupa

  • 03-23-2012 08:03 AM In reply to

    Re: Count multiple values in repeating table

    Oh, I made a mistake!

    count (../../OptGroup_EQUIPMENT/EQUIPMENT/equipmenttype[. = "Ladder" and ../EquipInsp = 'Fail'])

    Hilary Stoupa

  • 03-26-2012 03:56 AM In reply to

    • Laura
    • Top 500 Contributor
    • Joined on 08-27-2009
    • Posts 27

    Re: Count multiple values in repeating table

    Great, this works, I am thrilled.  Thank you for your time.

    Could you explain why using the full xpath did not work for the second reference (equipinsp = fail)?  It seems like using the full path would always work.

  • 03-26-2012 08:48 AM In reply to

    Re: Count multiple values in repeating table

    At the point where you are adding the filter, you are already at the child node. You have to use the relative path - in fact, you were using a relative path, but relative to the node the default was on. The error kind of tells you what was going on - it said that this:

    ../../OptGroup_EQUIPMENT/EQUIPMENT/equipmenttype/EquipInsp

    Did not point to a field or group.

    Hilary Stoupa

  • 05-18-2012 07:10 AM In reply to

    Re: Count multiple values in repeating table

    Will that formula work if the items you want to count are not in a repeating table?  In other words, I have over 100 controls and want to count them if they = pass or = deficiency.
  • 05-18-2012 08:29 AM In reply to

    Re: Count multiple values in repeating table

    Depending on your data source is organized, there may be a simpler way, but generally for disparate fields, the way to count how many have a certain value is:

    count((firstField | secondField | ... | lastField)[. = 'pass'])

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 2 (24 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.