+ Reply to Thread
Results 1 to 4 of 4

Average if values in adjacent columns is >0 AND adjust the average range each time

  1. #1
    Registered User
    Join Date
    10-11-2017
    Location
    London
    MS-Off Ver
    10
    Posts
    2

    Average if values in adjacent columns is >0 AND adjust the average range each time

    Hi Excel Forum!

    I have a challenge that I hope someone here can solve.

    I am trying to calculate an Average if the values in adjacent column are greater than zero AND shift the range of the average to start and finish for each section of rows that are greater than 0.

    Attached is a spreadsheet to give a clearer picture. In A2:A13, I have a sequence of ones and zeroes to indicate when the ranges to average. B2:B13 shows the data I want to average. B2:B13 is the correct answer. I'd like to be able to do this formulaically in column D as the real data set I have has varying number of rows between zeroes and ones and has >30,000 rows.

    Thanks in advance!!

    ew17
    Attached Files Attached Files
    Last edited by AliGW; 10-17-2020 at 01:06 PM. Reason: Solved tag correctly applied.

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: Average if values in adjacent columns is >0 AND adjust the average range each time

    Try this in D2:

    =IF(A2=0,0,IF(A2=1,IF(A1=1,D1,AVERAGE(OFFSET(B2,0,0,IFERROR(MATCH(0,A3:$A$14,0),ROWS(A3:$A$14)),1)))))

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Average if values in adjacent columns is >0 AND adjust the average range each time

    Try in D4:

    Please Login or Register  to view this content.
    Drag down

    Notice that I add one extra "0" in the last blank cell (A14) to make sure formula of last group cells of "1" work
    Attached Files Attached Files
    Quang PT

  4. #4
    Registered User
    Join Date
    10-11-2017
    Location
    London
    MS-Off Ver
    10
    Posts
    2

    Re: Average if values in adjacent columns is >0 AND adjust the average range each time

    Thank you, guys - SOLVED

+ 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. Replies: 5
    Last Post: 09-11-2018, 10:29 AM
  2. [SOLVED] Average ifs with multiple columns as the average range
    By moneypennie21 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-15-2017, 08:14 AM
  3. average ifs with average range in different lines / columns
    By campelliann in forum Excel General
    Replies: 2
    Last Post: 12-23-2015, 07:49 AM
  4. Average values if the associated time of occurence falls within a certain time range
    By boarderbrent91 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-02-2014, 01:49 PM
  5. Average range of cells in column if values in adjacent column are equal
    By RyNye in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-09-2012, 10:12 AM
  6. [SOLVED] Adjust macro to average three columns in C, D, & E
    By Nmoore in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 07-13-2012, 09:55 AM
  7. Replies: 11
    Last Post: 01-13-2011, 10:54 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