Average a group of fields only if they contain data - InfoPath Dev
in

InfoPath Dev

Average a group of fields only if they contain data

Last post 09-09-2011 12:16 PM by Jimmy. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-09-2011 11:16 AM

    • mrmapi
    • Not Ranked
    • Joined on 08-11-2011
    • Posts 7

    Average a group of fields only if they contain data

    I have a need for a group of fields to be averaged and have the average value displayed in a separate field.  There are 12 available fields but data is not required to be entered for each field.  Instead of averaging on the 12 fields, I need to be able to average based on the number of fields that have a value in them.  I was working with the avg() function where I created a group for the 12 fields but i am stuck on if there is a way to count the fields that have data.

    In my head i would like to do something like (Field1 + Field2 + Field3 + ...)/ (count of fields that have data) but I don't know how to complete the second portion. 

    The attachment just has three fields with the fourth field having an avg function for the group that contains the 3 fields.

    Thanks,

    Jason

  • 09-09-2011 12:16 PM In reply to

    Re: Average a group of fields only if they contain data

    avg((Field1 | Field2 | Field3 | ...)[. != ''])

    should do the trick

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