+ Reply to Thread
Results 1 to 4 of 4

IF Then - using 12 months - ongoing average

Hybrid View

  1. #1
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: IF Then - using 12 months - ongoing average

    Could you just post up your workbook so we don 't have to waste time reconstructing it to test...?

    GO ADVANCED and click on the paperclip icon.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

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

    Re: IF Then - using 12 months - ongoing average

    Given the 0 issue the area of interest thus becomes the rows above and how they are populated... for ex... I presume row 19 is the sum of rows 2:18, are these rows populated with 0's for future months ? If yes, would you EVER have 0's for all rows as valid results ?

    I would be inclined to alter the SUM in 19 such that a number is only displayed if there are actuals in preceding rows:

    B19: =IF(AND(COUNT(B2:B18),COUNTIF(B2:B18,"<>0")),SUM(B2:B18),"")
    copied to M19

    You can then just use a standard AVERAGE

    P19: AVERAGE(B19:M19)


    FYI:

    If 0 were not a potentially valid historical result the traditional approach would be one of:

    =AVERAGE(IF(B19:M19,B19:M19))
    entered with CTRL + SHIFT + ENTER

    or

    =AVERAGE(B19:INDEX(B19:M19,LOOKUP(2,1/(B19:M19<>0),COLUMN(B19:M19)-1)))

    (either way I make the Avg in your sample 4717.72)

  3. #3
    Registered User
    Join Date
    03-07-2009
    Location
    Birmingham, Al USA
    MS-Off Ver
    Excel 2003
    Posts
    44

    Re: IF Then - using 12 months - ongoing average

    [QUOTE=

    =AVERAGE(B19:INDEX(B19:M19,LOOKUP(2,1/(B19:M19<>0),COLUMN(B19:M19)-1)))

    [/QUOTE]

    This works great for what I was doing, yes I noticed later that my cut and paste into an example spreadsheet gave the wrong result, my actual spreadsheet was to big to post.

    Thank you DonkeyOte.

+ 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