+ Reply to Thread
Results 1 to 10 of 10

AverageIF and ABS function

  1. #1
    Registered User
    Join Date
    03-18-2011
    Location
    NY, NY
    MS-Off Ver
    Excel 2003
    Posts
    6

    AverageIF and ABS function

    All,

    Can someone advise me on this formula:


    =IFERROR(AVERAGEIF(AE4:AZ4,1,E4:Z4),"")


    How can you embed an ABS function in there? You cannot put it in here abs(E4:Z4) you will get error on the formula.


    appreciate any inputs.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AverageIF and ABS function

    Can you post your actual formula?
    I'm guessing that is an example because you're doing an average of all 1's.
    The average of all 1's is just 1, no matter how many there are.

    My bad, you're averaging E to Z, but counting 1's in AE to AZ..
    So nevermind that..

    Hang on, there's a way.
    Last edited by Jonmo1; 06-13-2013 at 01:19 PM.

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AverageIF and ABS function

    Try an array formula entered with CTRL + SHIFT + ENTER

    =IFERROR(AVERAGE(IF(AE4:AZ4=1,ABS(E4:Z4))),"")

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: AverageIF and ABS function

    AVERAGEIF (like other xxIF functions) requires ranges, not arrays, for both the criteria and the data to be averaged.

    =IFERROR(SUMPRODUCT((AE4:AZ4=1)*ABS(E4:Z4)) / COUNTIF(AE4:AZ4, 1), "")

    Quote Originally Posted by Jonmo
    =IFERROR(AVERAGE(IF(AE4:AZ4=1,ABS(E4:Z4))),"")
    Well, that's better!
    Last edited by shg; 06-13-2013 at 01:37 PM.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    03-18-2011
    Location
    NY, NY
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: AverageIF and ABS function

    Jonmo,

    Completely forgot about that function.

    Thanks a mill.

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AverageIF and ABS function

    Quote Originally Posted by shg View Post
    Well, that's better!
    Thanks alot!
    Last edited by Jonmo1; 06-13-2013 at 01:43 PM.

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: AverageIF and ABS function

    you can do it like this
    =SUMPRODUCT(--(AE4:AZ4=1),ABS(E4:Z4))/COUNTIF(AE4:AZ4,1)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: AverageIF and ABS function

    Just realized that. After you posted, and before I looked closely, I went to VBA to see what Intellisense said:

    WorksheetFunction.AverageIf(Arg1 as Range, Arg2, [Arg3])

    That, combined with the example I (thought I) saw, made me think I was wrong about the arguments. Intellisense shows the same for the other xxIf and xxIFS functions; only the first shows As Range.

    I feel ... betrayed.

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: AverageIF and ABS function

    Quote Originally Posted by pyrrhus272bc View Post
    Jonmo,

    Completely forgot about that function.

    Thanks a mill.
    You're welcome.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: AverageIF and ABS function

    The post editing has taken its toll, here, Jonmo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1