Average of 4 fields provided that they meet different conditions (>n) - InfoPath Dev
in

InfoPath Dev

Average of 4 fields provided that they meet different conditions (>n)

Last post 02-18-2011 03:15 PM by matt.steele. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-16-2011 09:39 AM

    Average of 4 fields provided that they meet different conditions (>n)

    Program: InfoPath2010 Designer

    Form: InfoPath 2007 compatible browser-enabled form

    Scenario: I have a browser-enabled form in which the totals from 4 sections are averaged in a "TotalChecklistCompliance" field.

    Very simple until...

    It has been requested that I re-work the average so that a given field is included in the averaging formula only if it has a value greater than 50. (Well, for 3 of the fields, anyway; the criteria for the 4th field is that it must be higher than 70 to be included in the averaging)

    How would I go about doing this? If only InfoPath could do a simple "AVERAGEIF" function. Or even an "IF"

    Thank you!

    ~Matt

  • 02-17-2011 05:21 AM In reply to

    Re: Average of 4 fields provided that they meet different conditions (>n)

    You can have multiple calculations and just display the one you want. So for example:

    field1 holds calculation #1, hidden for condition A

    field2 holds calculation #2, hidden for condition B

    etc.

    So in your case you might have field1= average of all 4 fields, and then only display this calculation if the fields all have a value greater than 50.

    field2 = average of 3 fields, only displayed when the excluded fields does not have value greater than 50,

    More is possible with code, but this seems like a simple way of approaching this problem codelessly.

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 02-18-2011 03:15 PM In reply to

    Re: Average of 4 fields provided that they meet different conditions (>n)

    Thanks, Ernesto

    I didn't use you solution, but it made me remember about how rules work.

    I created 4 new fields, and then attached rules to each of the the original 4 fields to set the value of the the new fields to equal the values of the original fields as long as they met the criterea OR to set the new fields values to "" (blank) if the original fields did not meet the critera.  Then I set the "total average" formula to average the new fields and used InfoPath's ability to ignore blank values in its calculations and viola!

    Thank you for your help! : )

    ~Matt

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.