+ Reply to Thread
Results 1 to 4 of 4

Monthly geomean with month and year criteria

  1. #1
    Registered User
    Join Date
    05-13-2018
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    2010
    Posts
    3

    Monthly geomean with month and year criteria

    Hi.
    I'm trying to find monthly geomean of the year 2008-2018 and dates are different. I found monthly arithmetic mean of returns by averageifs function by month, year criteria. however couldnt find geomean this way and any other way in these forum..It just calculates the mean of whole range and ignores the criterias, I guess. I have very large file so i wanted a function with less manual operations and click down entire area.

    Is there any way to find geomean with year and month criteria?

    =IF(AND($A$2:$A$1254=YEAR(C2);$B$2:$B$1254=MONTH(C2));0;GEOMEAN($J$2:$J$1254)-1)
    =GEOMEAN(IF(AND($A$2:$A$1254=YEAR(C2);$B$2:$B$1254=MONTH(C2));($J$2:$J$1254)-1) ctrl+shift+enter
    'and' function doesnt work with range frormulas i guess. Then how to add multiple criteria? IFS didnt work or i missed something.
    Attached Files Attached Files
    Last edited by Azopt; 05-15-2018 at 08:11 AM. Reason: i didnt desribe my idea well

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Monthly geomean with month and year criteria

    The issue seems to be how you defined your array formulas. First of all, I took the liberty of converting the data in your data range into an Excel table. In this case, it was mostly a matter of convenience since you can address table columns by their name rather than cell references. This makes it easier to tell what the formula is doing. Tables also have a lot of other advantages: http://www.utteraccess.com/wiki/Tables_in_Excel

    So the monthly Geomean is: =GEOMEAN(IF([Year]=[@Year],IF([Month]=[@Month],[value],FALSE))) as an array formula.

    One trick to constructing an array formula of this type is to pretend you are working with just a single row and develop an IF statement that yields TRUE or FALSE. In this case we could make an if statement =AND (year=year,month=month) but that won't work for an array formula. To make the analogy, you need to nest the if statements. =IF(year = year, IF(month=month, Use Range, False)).

    I like to call out the False explicitly. You don't have to do that since the default is if the IF statement fails, then the result defaults to False.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Monthly geomean with month and year criteria

    @azopt.... Array-enter (press ctrl+shift+Enter instead of just Enter), as you indicated:

    =GEOMEAN(IF($A$2:$A$1254=YEAR(C2);IF($B$2:$B$1254=MONTH(C2);$J$2:$J$1254))) - 1
    or
    =GEOMEAN(IF($A$2:$A$1254=YEAR(C2);IF($B$2:$B$1254=MONTH(C2);1+$E$2:$E$1254))) - 1

    We cannot use AND in an array-entered formula because the AND function "swallows" its array parameter "whole", since that is its normal behavior. In other words, array-entered AND($A$2:$A$1254=YEAR(C2);$B$2:$B$1254=MONTH(C2)) returns a single TRUE or FALSE result based on the array of conditions (i.e. TRUE if all of the rows have the year and month), instead of the row-by-row TRUE or FALSE result that you intend (i.e. TRUE if that row has the year and month).
    Last edited by joeu2004; 05-15-2018 at 11:50 AM. Reason: minor

  4. #4
    Registered User
    Join Date
    05-13-2018
    Location
    Ulaanbaatar, Mongolia
    MS-Off Ver
    2010
    Posts
    3

    Re: Monthly geomean with month and year criteria

    Thank you so much dflak, joeu 2004. You brighten my day.

+ 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. VLOOKUP with Month-Year and numbers criteria
    By axangec in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-24-2016, 06:41 AM
  2. Replies: 3
    Last Post: 02-03-2016, 01:53 PM
  3. [SOLVED] Sumproduct with month, year, other criteria, and blank
    By bibbi2 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-29-2015, 12:47 AM
  4. Replies: 18
    Last Post: 09-08-2014, 05:06 PM
  5. VBA autofilter using only year or month as criteria
    By torppo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2014, 02:22 AM
  6. If Column A Month and Year = ColumnB Todays Month and Year then send email
    By HACCStaff in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-15-2013, 12:47 AM
  7. Using SUMPRODUCT For Two Criteria AND Month of Year.
    By stuu3270 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-16-2013, 06:22 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