+ Reply to Thread
Results 1 to 5 of 5

Computing an average with multiple criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    08-09-2024
    Location
    Boston, MA
    MS-Off Ver
    Excel 365
    Posts
    3

    Computing an average with multiple criteria

    Hello all - new to this forum but not new to Excel - I work in the environmental engineering consulting industry.

    I have a need to calculate an average of a monthly value (say rainfall) for each month of the year over multiple years while accounting for leap years. The partially processed data look something like this where a monthly average value is calculated from a large table assuming the daily values are either from a non-leap year or from a leap year (one extra day in February occurring every 4th year). I don't have the luxury to reformat the data.

    Year Month NonLeap Leap
    1 Jan 3.0 3.5
    2 Jan 2.0 2.5
    3 Jan 4.0 4.2
    4 Jan 2.5 2.5
    5 Jan 1.5 1.6
    6 Jan 3.8 3.7
    7 Jan 4.1 4.2
    8 Jan 3.3 3.5

    For this example, the average of the bold values would calculated.
    The example spreadsheet has data for each month for 8 years and the desired outcome.

    TIA
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,645

    Re: Computing an average with multiple criteria

    Have you tried a Pivot Table?
    Attached Files Attached Files
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  3. #3
    Registered User
    Join Date
    08-09-2024
    Location
    Boston, MA
    MS-Off Ver
    Excel 365
    Posts
    3

    Re: Computing an average with multiple criteria

    popipipo - Thanks for the suggestion - I'm looking for a formula approach as this calculation is part of an VBA application in Excel - something I didn't include in the original post.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,705

    Re: Computing an average with multiple criteria

    Try

    Formula: copy to clipboard
    =SUMPRODUCT(($B$2:$B$97=F2)*(($C$2:$C$97)*(MOD($A$2:$A$97,4)<>0)+($D$2:$D$97)*(MOD($A$2:$A$97,4)=0))/SUMPRODUCT(--($B$2:$B$97=F2)))
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Registered User
    Join Date
    08-09-2024
    Location
    Boston, MA
    MS-Off Ver
    Excel 365
    Posts
    3

    Re: Computing an average with multiple criteria

    Quote Originally Posted by JohnTopley View Post
    Try

    Formula: copy to clipboard
    =SUMPRODUCT(($B$2:$B$97=F2)*(($C$2:$C$97)*(MOD($A$2:$A$97,4)<>0)+($D$2:$D$97)*(MOD($A$2:$A$97,4)=0))/SUMPRODUCT(--($B$2:$B$97=F2)))
    That will answer the mail. Thanks, John!

+ 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] Computing average to be linked in another sheet
    By Simply_Me in forum Excel General
    Replies: 10
    Last Post: 03-28-2019, 12:57 AM
  2. Computing Percentiles based on multiple criteria
    By alwaysandalways in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-20-2015, 01:59 AM
  3. [SOLVED] Macro computing average and Q1 and Q3 of raw data
    By Settler7 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-12-2015, 02:26 AM
  4. Computing Summary Table from Multiple Criteria
    By sdemaere in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2012, 07:59 PM
  5. computing for scores (average)
    By drcbedana in forum Excel General
    Replies: 1
    Last Post: 12-30-2010, 07:24 AM
  6. Computing Average
    By jagannathkiran in forum Excel General
    Replies: 4
    Last Post: 06-28-2010, 06:59 AM
  7. computing weekly average
    By j_blocker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2007, 12:43 AM

Tags for this Thread

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