+ Reply to Thread
Results 1 to 14 of 14

Averaging non-contigious ranges in Excel (excluding zeros)

  1. #1
    Registered User
    Join Date
    03-01-2023
    Location
    London
    MS-Off Ver
    Microsoft 365
    Posts
    8

    Unhappy Averaging non-contigious ranges in Excel (excluding zeros)

    Hello. I hope this post finds you well.

    I work for a hospitality company that want to find their full year average occupancy % as the year progresses.

    The columns of the excel sheet are currently:
    Jan 8th | Jan 15th | Jan 22nd | Jan 29th | JAN MTD AVERAGE | JAN TRAILING 3-MTH AVERAGE | Feb 5th | Feb 12th ... and so on.

    I need to include the week data (%), but not the MTD AVERAGE or TRAILING 3 MONTH AVERAGEs columns, into a single FY average at the end of the year (which does not include zeros for the weeks which haven't happened yet)

    I thought the correct formula would be (assuming starting cell A1):

    =AVERAGEIFS(A1:D1,A1:D1,">0",G1:J1,G1:J1,">0",M1:P1,M1:P1,">0"))), etc. However this is returning a #ERROR!.

    Am I simply missing a bracket somewhere? Can't really change the format of the spreadsheet now, it's a legacy one I've picked up and the site teams are used to the format.

    Any guidance gratefully received. Thank you.

  2. #2
    Registered User
    Join Date
    03-01-2023
    Location
    London
    MS-Off Ver
    Microsoft 365
    Posts
    8

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    Also, wanted to introduced myself more politely on the correct page, but was afraid to lose my thread. My name is James and I work in Finance at a UK-based hospitality company. Great to meet you all

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,811

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    03-01-2023
    Location
    London
    MS-Off Ver
    Microsoft 365
    Posts
    8

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    MaverickJC - AVERAGEIFS proforma.xlsx

    I need CB2 to averageIF all the green cells (excluding any zeros), and also help with the MTD averages where they have zero data to calculate and return #DIV/0!

    Thank you so much.
    Last edited by MaverickJC; 03-01-2023 at 10:17 AM.

  5. #5
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,121

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    Welcome to the forum, MaverickJC!

    Try, =SUMPRODUCT(A1:P1*NOT(ISFORMULA(A1:P1)))/SUM(NOT(ISFORMULA(A1:P1))*1)

  6. #6
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2405-17628.20102
    Posts
    1,392

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    For CB2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The first six characters of the corresponding cell in the range C1:BZ1 must be "Sunday".
    The value in the cell must be greater than zero.

    Here's a breakdown of how the formula works:

    The LET function allows you to define a named variable ("f") that represents the result of a FILTER function.
    The FILTER function returns an array of values that meet the specified conditions. In this case, it returns a filtered array of values from C2 to BZ2 where the first six characters of the corresponding cell in C1 to BZ1 are "Sunday".
    The named variable "f" is used as the input array for the AVERAGE function, which returns the average value of the filtered array of values, but only for values that are greater than zero.
    So in summary, this formula calculates the average value of cells in the range C2:BZ2 where the first six characters of the corresponding cell in the range C1:BZ1 are "Sunday" and the cell value is greater than zero.
    Last edited by CheeseSandwich; 03-01-2023 at 10:52 AM.
    If things don't change they stay the same

  7. #7
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2405-17628.20102
    Posts
    1,392

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    For your MTD:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Or:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,121

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    Try, =AVERAGEIF(C$1:BZ$1,"Sunday*",C2:BZ2)

  9. #9
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,796

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    CB2=AVERAGE(FILTER(FILTER(C2:BZ2,(ISNUMBER(SEARCH("2023",C1:BZ1))*(ISNUMBER(C2:BZ2)))),FILTER(C2:BZ2,(ISNUMBER(SEARCH("SUNDAY",C1:BZ1))*(ISNUMBER(C2:BZ2))))>0))

    or

    CB2=AVERAGE(IF(ISNUMBER(SEARCH("2023",C1:BZ1)),IF(C2:BZ2>0,C2:BZ2))) for office365 20121 only enter for other control+shift+enter

  10. #10
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,121

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    Or, =AVERAGEIFS(C2:BZ2,C2:BZ2,">0",C$1:BZ$1,"Sunday*"), to exclude 0%

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,811

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    Wow, I turn my back and it's like a feeding frenzy!

  12. #12
    Registered User
    Join Date
    03-01-2023
    Location
    London
    MS-Off Ver
    Microsoft 365
    Posts
    8

    Talking Re: Averaging non-contigious ranges in Excel (excluding zeros)

    Thank you so much everyone! Very grateful for your input.

  13. #13
    Registered User
    Join Date
    03-01-2023
    Location
    London
    MS-Off Ver
    Microsoft 365
    Posts
    8

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    Hi CARACALLA,

    Please may I confirm if this formula would work for numbers rather than percentages?
    CB2=AVERAGE(FILTER(FILTER(C2:BZ2,(ISNUMBER(SEARCH("2023",C1:BZ1))*(ISNUMBER(C2:BZ2)))),FILTER(C2:BZ2,(ISNUMBER(SEARCH("SUNDAY",C1:BZ1))*(ISNUMBER(C2:BZ2))))>0))

    If works perfectly on the rows with percentages (thank you!) but not on those with numbers.
    Last edited by MaverickJC; 03-02-2023 at 08:40 AM.

  14. #14
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,723

    Re: Averaging non-contigious ranges in Excel (excluding zeros)

    It may help us understand the issue if we could see a sample row that is not yielding the correct result.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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] Count Cells Excluding Blanks, Zeros, and Formulas Returning Zeros
    By Saradomin in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-10-2022, 05:14 AM
  2. Averaging percentages, excluding zeros
    By Sophocles84 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-25-2018, 11:15 PM
  3. Replies: 1
    Last Post: 08-11-2016, 03:09 PM
  4. [SOLVED] macro to sum amount in contigious and non contigious columns
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2016, 03:32 PM
  5. [SOLVED] Averaging across multiple ranges, not counting zeros, and the [h]:mm format
    By Alphabex in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-28-2016, 03:43 PM
  6. [SOLVED] Average for non-consecutive cells excluding zeros (even when they all contain zeros)
    By pao13 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2012, 04:32 PM
  7. Averaging with zeros NOT
    By Tom in forum Excel General
    Replies: 5
    Last Post: 08-18-2005, 03:05 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