+ Reply to Thread
Results 1 to 15 of 15

Averageif function with Average range subtracting columns

  1. #1
    Registered User
    Join Date
    07-18-2014
    Location
    Rhode Island
    MS-Off Ver
    2007
    Posts
    18

    Averageif function with Average range subtracting columns

    Hello!

    I found a similar topic but I opened another one because I didn't really understand how to do this.

    OK... so I have a spreadsheet with all these different dates and instead of having to create a column every time I want to subtract one from the other, I'd rather have the function do that for me (which it does). The problem is that it shows as invalid.

    So for example I have

    PO Create Date STA Date
    3/18/2014 5/27/2014
    3/18/2014 5/27/2014
    3/18/2014 6/24/2014

    I want my average if to subtract the 2 values instead of having to create a column to do that for me.

    I hope you guys understand what I'm trying to do here!

  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 function with Average range subtracting columns

    So you want the average of column B minus Column A ?

    Try an array formula entered with CTRL + SHIFT + ENTER
    =AVERAGE(B2:B100-A2:A100)

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

  3. #3
    Registered User
    Join Date
    07-18-2014
    Location
    Rhode Island
    MS-Off Ver
    2007
    Posts
    18

    Re: Averageif function with Average range subtracting columns

    Yes, in this case it would be an average if. Can I do the same thing if I use average if?

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

    Re: Averageif function with Average range subtracting columns

    No, AverageIF won't be able to do it.
    But you can still use an Array Formula Average(If

    =AVERAGE(IF(A1:A100="criteria",C1:C00-B1:B100))

    Still entered with CTRL + SHIFT + ENTER
    That will give an average of C-B IF A="criteria"

  5. #5
    Registered User
    Join Date
    07-18-2014
    Location
    Rhode Island
    MS-Off Ver
    2007
    Posts
    18

    Re: Averageif function with Average range subtracting columns

    Worked perfectly!!! Although I have to leave the header out. Since this is a tab that will have constant updates and we'll be adding more rows of info what should I do in terms of the range, A1:A9999999?

  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 function with Average range subtracting columns

    No, don't do that..

    You should have a 'reasonable' expected upper limit to the # of records in the file.
    Add 10% to that.

    If you can't come up with a reasonable limit, look into using Dynamic Named ranges.
    Or do
    =(SUMIF(A:A,"criteria",C:C)-SUMIF(A:A,"Criteria",B:B))/COUNTIF(A:A,"criteria")

    The count/sum/average IF functions are smart enough to only process the actual used range.
    But an array formula Average(IF is not, it will evaluate every single row. = Poor Performance.

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

    Re: Averageif function with Average range subtracting columns

    Although, you already touched on the best solution yourself.
    Quote Originally Posted by miguelcristovao View Post
    instead of having to create a column to do that for me.
    That really is the best/most efficient solution.
    To put =C2-B2 in column D then use that in the average.


    I don't understand why so many people are against using additional columns for calculations.
    It's not a bad thing.
    Excle gives you over 16000 columns, might as well use a few of them here and there.

  8. #8
    Registered User
    Join Date
    07-18-2014
    Location
    Rhode Island
    MS-Off Ver
    2007
    Posts
    18

    Re: Averageif function with Average range subtracting columns

    That works way better actually!!! Thank you so much

    Yes I know, but what happens is that I'm trying to create a system where someone else just has to come to this tab and copy paste it without having the need to create the column all over again. This function captures the info all at once which is perfect

  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 function with Average range subtracting columns

    Quote Originally Posted by miguelcristovao View Post
    without having the need to create the column all over again.
    Don't they already have to modify it a little by putting in the formula? They can't put in 2 formulas?

  10. #10
    Registered User
    Join Date
    07-18-2014
    Location
    Rhode Island
    MS-Off Ver
    2007
    Posts
    18

    Re: Averageif function with Average range subtracting columns

    I have a tab where you throw all the info in and another tab that has all the formulas. Basically a tab that works as a table and another that works like a query

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

    Re: Averageif function with Average range subtracting columns

    Then I don't understand why you can't have the helper column of =C2-B2 then?

    Supposedly it would have to reference the sheet that has the data
    =Data!C2-Data!B2

  12. #12
    Registered User
    Join Date
    07-18-2014
    Location
    Rhode Island
    MS-Off Ver
    2007
    Posts
    18

    Re: Averageif function with Average range subtracting columns

    I see what you're saying but I'd need multiple columns with that info and then a simple AVG function would do the same thing. I'm just trying to make this more effecient... with a more complicated formula I guess.

    Any chance you can help me with with Listing Unique values? I can't make this Index, Match, Countif thing work!

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

    Re: Averageif function with Average range subtracting columns

    I would submit that using the helper column IS more efficient then combining the calcs into 1 formula.

    Also, I find in many cases that it's helpful to have the 'intermediate' calculation in it's own cell for future reference.
    You never know if a couple weeks later, you have a requirement to see what C-B actually was.
    Then you'll be making another formula to show that, and now you have 2 formulas doing the same work twice.


    I'd start another thread for listing unique values.
    It's not my specialty, but there are several others who are quite good at it.

  14. #14
    Registered User
    Join Date
    07-18-2014
    Location
    Rhode Island
    MS-Off Ver
    2007
    Posts
    18

    Re: Averageif function with Average range subtracting columns

    OK thanks for the heads up. I'll take on your advice and actually do that, totally forgot to see it from that prisma! Once again, thank you

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

    Re: Averageif function with Average range subtracting columns

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. AVERAGEIF function for multiple columns.
    By thatguytg53 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-11-2014, 06:17 PM
  2. AVERAGEIF function using reference as criteria range
    By AndySan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-05-2013, 05:35 PM
  3. [SOLVED] Averageif(range,monthcriteria,[average range])???
    By athyeh in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-19-2013, 12:09 PM
  4. [SOLVED] Excel 2010 AVERAGEIF function to average two different columns on two different tabs
    By stevemills04 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-05-2013, 01:48 PM
  5. Excel 2007 : AVERAGEIF range function
    By Jerseynjphillypa in forum Excel General
    Replies: 1
    Last Post: 07-16-2012, 10:45 AM

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