+ Reply to Thread
Results 1 to 6 of 6

Calc median over a date range.

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Calc median over a date range.

    I have a file (see enclosed).

    On the raw_data sheet i have a percentages column with the corresponding date columns.

    If you look at the summary sheet i list a date range in row 2. Start date range is listed in A2 and end date range is listed in cell B2.

    What i want is to calculate the median value of the percentage column based on the date values in cells A2 and B2. I am not sure how to do this.
    Attached Files Attached Files
    Last edited by welchs101; 10-06-2011 at 03:17 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Calc median over a date range.

    Try:

    =MEDIAN(IF(Raw_Data!$C$2:$C$41>=A2,IF(Raw_Data!$C$2:$C$41<=B2,Raw_Data!$D$2:$D$41)))

    confirmed with CTRL+SHIFT+ENTER not just ENTER
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Calc median over a date range.

    works great! thanks.

    I was just wondering ..........why? Why did it work?

    I know that by hitting cntrl+shift+enter your using an array of something but i did not know you could do this on just any thing.

    thanks again!!!!!!!!!!!!!!

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Calc median over a date range.

    It is finding the Median based on conditions.. you can use this logic as if it were a form of SUMIF(S) or COUNTIF(S). Excel 2007 introduced AVERAGEIF which we used to have to work out using similar array formula construct of AVERAGE(IF(....)).

    So the formula builds an array of TRUES and FALSES for each IF statement.. and then "blends" them so that TRUES that line up become TRUE and all other combos yield FALSE... then the TRUEs are lined up with the final array to find which lines up with the TRUE(s) and finds the MEDIAN from those.

    You can use the Evaluate Formula function found in the Tools|Formula Auditing menu in XL2003 and in the Formulas tab of XL2007 or later. This tool allows you to step through the formula to see what's happening and how you achieve the result you got.

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,662

    Re: Calc median over a date range.

    very cool! i did not know about this. I have tended to stay away from these "array" type formulas and to be honest i dont remember why.

    Is there any other "literature" type stuff on this so i can read it and perhaps apply this to someother issue i may have.......

    thanks again.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Calc median over a date range.

    If you google "Array Formulas" you will come up with some good stuff on them.

+ 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