+ Reply to Thread
Results 1 to 13 of 13

Averageifs formula with criteria as formulas

  1. #1
    Registered User
    Join Date
    10-17-2012
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Averageifs formula with criteria as formulas

    I am using the averageifs formula and I have two criteria to meet (state and year). Everything seems to work fine when I type my criteria in as a value, but when I put it in as a cell reference the formula doesn't work. For example, the following formula works fine:

    =AVERAGEIFS($R$9:$R$2387,$N$9:$N$2387,"="&$BZ13,$M$9:$M$2387,">=1951",$M$9:$M$2387,"<=2011")*100 -- "$BZ13" refers to a state reference. However, when I replace the "<=2011" with "<="&$CB$3 (i.e., a cell reference for year) the formula does not work. Any idea what I'm doing wrong? Thanks.

  2. #2
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Averageifs formula with criteria as formulas

    Formulas within a formula do not start with =
    When I say semicolon, u say comma!

  3. #3
    Registered User
    Join Date
    10-17-2012
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Averageifs formula with criteria as formulas

    Not sure what you mean by that as I don't have any formula within the AVERAGEIFS formula starting with "=". I do use the "=" and "<=" and ">=" symbols for my criteria. What I am trying to do is take the average of an array (R9:R2387) if the value is from a particular state (N29:N2387 = value in BZ13) and meeting a year requirement (M9:M2387 less than or equal to 2011 and greater than or equal to 1951 -- it is the 2011 and 1951 that I want to make into a cell reference). That is, I'm wanting the average value that meets three criteria (state=value in BZ13, year<=2011, and year>=1951).

  4. #4
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Averageifs formula with criteria as formulas

    Ah I see. But why are you typing the criteria like "="&$BZ13? Does =$BZ13 not work?

  5. #5
    Registered User
    Join Date
    10-17-2012
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Averageifs formula with criteria as formulas

    =$BZ13 does not work in the AVERAGEIFS formula to the best of my knowledge. What I'm confused about is why the "="&$BZ13 works, but I can't use the same approach for the ">" or "<" operators.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Averageifs formula with criteria as formulas

    "<="&$CB$3 should work fine as a substitute for "<=2011" as long as CB3 contains 2011.....

    ...but you say it doesn't work. Does CB3 perhaps contain a date, formatted to show the year? If so you'll need

    "<="&YEAR($CB$3)
    Audere est facere

  7. #7
    Registered User
    Join Date
    10-17-2012
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Averageifs formula with criteria as formulas

    I have checked both the values in my column of data with years and verified that all the data are values (1951-2012) and the value I had in my criteria cell (CB3) was also a value. Bottom line, I can't figure out what is wrong as I've checked data and formulas several times and everything seems fine.

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Averageifs formula with criteria as formulas

    OK you say that using CB3 doesn't work. What result do you get? I assume you get the wrong value rather than an error?

    Can you try this formula in a blank cell

    =YEAR(CB3)

    what result do you get?

  9. #9
    Registered User
    Join Date
    10-17-2012
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Averageifs formula with criteria as formulas

    I get an error (i.e., #DIV/0!). When I use =YEAR(CB3), where CB3=2011, I get 1905, which is a value that is not in my array (column of year values). However, I actually am never using the "YEAR" command anywhere. That is, what I have in column M (see initial formula) are values of 1951-2011 and they represent years, but I'm never technically telling Excel these are years (i.e., they are simply values).

  10. #10
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Averageifs formula with criteria as formulas

    Could you upload a file where this happens? Because now we are just guessing in the dark.

  11. #11
    Registered User
    Join Date
    10-17-2012
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Averageifs formula with criteria as formulas

    The file I've uploaded (hopefully it has been uploaded properly) shows the problem I'm having. Column H has the correct answer, but you can see that I typed "1951" and "2011" into the formula. Column I has the formula I would like to use, which seems I should be able to, but something is obviously wrong. Thanks.
    Attached Files Attached Files

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Averageifs formula with criteria as formulas

    Nothing wrong with your formula but you have an obscure setting turned on....

    Go to File > Options > Advanced > scroll right down to the bottom and untick "Transition formula evaluation"

    That should make your formula work

  13. #13
    Registered User
    Join Date
    10-17-2012
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Averageifs formula with criteria as formulas

    Nice catch! I forgot that I turned that on. Of course this is going to cause more problems for me because I'm in the process of converting an old Lotus file to Excel (showing my age a little there). When I "untick" this, I have other formulas in the spreadsheet that will blow-up, but I can redo them by changing the syntax. Thanks for the help!

+ 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. [SOLVED] Averageifs with multiple criteria
    By jbillyo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-02-2013, 04:13 PM
  2. [SOLVED] Several formulas with specific range criteria (AVERAGEIFS, STDEV(IF), COUNTIFS)
    By thaphthia in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 04-11-2013, 05:22 PM
  3. AVERAGEIFS with no criteria
    By anteagles20 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-14-2013, 10:10 AM
  4. Averageifs with OR criteria
    By Subject_Name_Here in forum Excel General
    Replies: 5
    Last Post: 05-28-2012, 01:57 PM

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