+ Reply to Thread
Results 1 to 5 of 5

AVERAGE and Conditional formula...

  1. #1
    Registered User
    Join Date
    06-14-2004
    Posts
    75

    Lightbulb AVERAGE and Conditional formula...

    Afternoon all!

    I am trying to calculate an average case cost based on several case costs... so far so good

    The problems I have are as follow:

    - The way the spreadsheet is setup means that the various case costs are not in a range but in seperate cells eg. D70, H70, L70, P70, T70, [...], BD70

    - As i want to calculate an average I want to AVERAGE() formula to only take into account the cells where cell is not equal to zero... otherwise my average is inacurate as it will take into account all cells...

    So there i am. I do not know how to setup an average forumal that will take into account the condition that each of the cells are superior to zero...

    I hope that you guys can help!!

    Thanks!

  2. #2
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Try the following formula...

    =AVERAGE(IF((MOD(COLUMN(D70:BD70)-CELL("col",D70)+0,4)=0)*(D70:BD70<>0),D70:BD70))

    ...confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

    Hope this helps!

    Quote Originally Posted by Petitboeuf
    Afternoon all!

    I am trying to calculate an average case cost based on several case costs... so far so good

    The problems I have are as follow:

    - The way the spreadsheet is setup means that the various case costs are not in a range but in seperate cells eg. D70, H70, L70, P70, T70, [...], BD70

    - As i want to calculate an average I want to AVERAGE() formula to only take into account the cells where cell is not equal to zero... otherwise my average is inacurate as it will take into account all cells...

    So there i am. I do not know how to setup an average forumal that will take into account the condition that each of the cells are superior to zero...

    I hope that you guys can help!!

    Thanks!
    Last edited by Domenic; 02-17-2005 at 11:29 PM.

  3. #3
    Registered User
    Join Date
    06-14-2004
    Posts
    75

    Talking

    Thanks Domenic!!

    It worked like a dream


    ... any chance of getting an explanation (detailed ) of the formula? I get it but would be incapable of reproducing it...

    Many thanks in advance!!!
    Last edited by Petitboeuf; 02-21-2005 at 12:14 PM.

  4. #4
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Assuming that A1:A5 contains the following values...

    10
    15
    0
    8
    12

    ...and that we'd like to average every 2nd value, excluding zero's, using the following formula...

    =AVERAGE(IF((MOD(ROW(A1:A5)-CELL("row",A1)+0,2)=0)*(A1:A5<>0),A1:A5))


    (MOD(ROW(A1:A5)-CELL("row",A1)+0,2)=0) returns the following ...

    TRUE
    FALSE
    TRUE
    FALSE
    TRUE

    (A1:A5<>0) returns...

    TRUE
    TRUE
    FALSE
    TRUE
    TRUE

    When these two are combined, forming the first arguement of the IF function...

    (MOD(ROW(A1:A5)-CELL("row",A1)+0,2)=0)*(A1:A5<>0) returns the following array...

    1
    0
    0
    0
    1

    Note that the numerical equivalent of TRUE/FALSE is 1/0, respectively. Therefore,

    =TRUE*TRUE equals 1
    =TRUE*FALSE equals 0

    IF((MOD(ROW(A1:A5)-CELL("row",A1)+0,2)=0)*(A1:A5<>0),A1:A5) returns...

    10
    FALSE
    FALSE
    FALSE
    12

    Lastly, the AVERAGE function averages these values, ignoring the FALSE values.

    Hope this helps!

    Quote Originally Posted by Petitboeuf
    Thanks Domenic!!

    It worked like a dream


    ... any chance of getting an explanation (detailed ) of the formula? I get it but would be incapable of reproducing it...

    Many thanks in advance!!!

  5. #5
    Registered User
    Join Date
    06-14-2004
    Posts
    75
    Crystal clear! Thanks for that!

+ 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