+ Reply to Thread
Results 1 to 5 of 5

averaging varying column entries

Hybrid View

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    averaging varying column entries

    Hi
    been away from this type of work for a while so am finding myself very rusty


    have weekly data pulled from transport figures to give mpg figures, which are then averaged to give a figure for the 4week or a 5week month.

    Sheet then displays highest and lowest results in range by driver name


    I have just noticed an anomoly when the vehicle is NOT used and returns a no value in the cell range. In this instance the average formula should use the number of weeks there is a figure for as the base for the average

    entry line would look like

    wk1 wk2 wk3 wk4 AVE
    5.1 5.8 6.0 5.6 AVERAGE(WK1:WK4) 5.625
    5.1 x 6.0 5.6 AVERAGE(WK1:WK4 - divided by 3 in this case) 5.56 not 4.175

    any help appreciated
    Last edited by nigelog; 04-07-2010 at 08:47 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: averaging varying column entries

    Can you elaborate as to what "no value" actually constitutes - presumably 0 ?

    (any other value - ie blank / non-numeric and the AVERAGE function would work correctly regardless)

    Assuming then a 0 value for "no value" then:

    Pre XL2007 functions

    =SUM(A2:D2)/COUNTIF(A2:D2,">0")

    XL2007

    =AVERAGEIF(A2:D2,">0")

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: averaging varying column entries

    thanks donkeyote

    nearly there - only problem is if all 4 values 0

    (actually displays an X something I did on the original weekly sheet - =IF(ISERROR(SUM(O14/(M14/4.546))),"X",SUM(O14/(M14/4.456))),

    EDIT:

    have changed above to give "0" values - =IF(ISERROR(SUM(O14/(M14/4.546))),"X",SUM(O14/(M14/4.456))),

    calculation returns #DIV/0! value which messes up formulae for calculating largest and smallest - can I get it to display "0"

    much appreciated
    Last edited by nigelog; 04-07-2010 at 08:43 AM.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: averaging varying column entries

    If 0 is preferred then perhaps simplest to encase the divisor within a MAX call

    =SUM(A2:D2)/MAX(1,COUNTIF(A2:D2,">0"))

    ie divisor never < 1

  5. #5
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: averaging varying column entries

    Thanks DonkeyOte - sorted

    much appreciated

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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