+ Reply to Thread
Results 1 to 10 of 10

Formula to filter out the year based on a list of dates

  1. #1
    Registered User
    Join Date
    07-07-2015
    Location
    England
    MS-Off Ver
    MS Office 2010
    Posts
    69

    Formula to filter out the year based on a list of dates

    Hi,

    I currently have a bunch of data with multiple days and multiple years. I am trying to look at individual years and analyse the max, avg, min, 95%ile etc. Currently I am selecting the relevant cells which becomes tedious. I tried with an IF statement =AVERAGEIF(A2:A165="2011",A2:A3,NA()) but that didn't work. I also tried a Pivot table.

    Can someone help me with this please?

    Also regarding the 95%ile calculations. I have seen different methods of calculating it. PERCENTILE, PERCENTILE.INC, PERCENTILE.EXC. I have calculated it based on a way I saw online =LOGINV(0.95,AVERAGE(C2:C21),STDEV(C2:C21)) but don't understand why this is supposed to be better (apparently it is).

    Thanks for your help.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,562

    Re: Formula to filter out the year based on a list of dates

    I have array entered formulas* for MAX, AVERAGE and MIN.
    For MAX use: =MAX(IF(YEAR(A$2:A$165)=E5,B$2:B$165))
    For AVERAGE use: =AVERAGE(IF(YEAR(A$2:A$165)=E5,B$2:B$165))
    For MIN use: =MIN(IF(YEAR(A$2:A$165)=E5,B$2:B$165))
    *Array entered formulas are confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    I will have to come back to the 95%ile later, if someone has not already given you a solution by then.
    I'll also add that your pivot table on sheet 2 seems work if you group your dates by year.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,562

    Re: Formula to filter out the year based on a list of dates

    For 95%ile calculation try the following:
    1) Select cell I5,
    2) Paste the following array entered formula into the formula bar:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    3) Simultaneously press the Ctrl, Shift and Enter keys,
    4) drag the fill handle down to I11.
    Let us know if you have any questions.

  4. #4
    Registered User
    Join Date
    07-07-2015
    Location
    England
    MS-Off Ver
    MS Office 2010
    Posts
    69

    Re: Formula to filter out the year based on a list of dates

    That's great. That works really well. How did you organise the pivot so that it showed years instead of dates?

    I also tried to apply the same formula to more raw data which I believes requires an AND into the function

    =MAX(IF(AND(YEAR($A$2:$A$165)=$G5,B2:B165=H2,C2:C165=H3)),$D$2:$D$165).

    I'd like to look at the MAX of each year (e.g. 2011) at a specific location (A) and of the same determinant (pH). The equation I posted above does not work.

    Can you please advise?

    And can this be done with a pivot table too?
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-07-2015
    Location
    England
    MS-Off Ver
    MS Office 2010
    Posts
    69

    Re: Formula to filter out the year based on a list of dates

    Hi again,

    I am having more issues as the equation does not want to work anymore. Another set of data points had many zeros in it and I replaced them all with blank cells. Despite this, the MAX, AVG, MIN are returning as #N/A. And the 95%ile also does the same as I had a look at the data and it may be taking into account that Ln(0) is #NUM! and they are also other values that are negative.

    Please help!
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,562

    Re: Formula to filter out the year based on a list of dates

    As to the dates, pick out one and right click the mouse, then choose group, selecting year and deselecting month.
    As to the formula try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    As to using a pivot table, yes. I have set up a pivot table on sheet 2 that uses location and determinant as report filters. I believe that a pivot table will be your best option with a file the size of the one attached to post #5. I will have to do some research on finding out how/if it is possible to obtain the 95 percentile on the pivot table, unless of course someone else solves that first.
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,562

    Re: Formula to filter out the year based on a list of dates

    I am going to have to admit failure with obtaining the 95th percentile using the loginv function for the file attached to post #5.
    As to the file attached to post #5 the file it is too large for me to upload so I will have to explain as much as I was able to do:
    1) It appears that the values in column B are text not dates - Notice that about row 1154 the value is 13/1/2012 - I used the text to columns feature on the data tab to change this.
    a) I selected B2 and pressed Ctrl and the down arrow to select the column,
    b) I opened the text to columns feature,
    c) I selected 'Next' twice then selected Date: DMY and 'Finish'
    2) I placed the following array entered formula in I2: =MAX(IF(YEAR(B$2:B$194000)=H2,D$2:D$194000))
    3) After simultaneously pressing the Ctrl, Shift and Enter keys I dragged the fill handle down to I7
    4) I repeated steps 2 and 3 for the average column using the array entered formula: =AVERAGE(IF(YEAR(B$2:B$194000)=H2,D$2:D$194000))
    and with the MIN column using: =MIN(IF(YEAR(B$2:B$194000)=H2,D$2:D$194000))
    As I said I failed to get a 95%ile using LOGINV so I used the array formula: =PERCENTILE.INC(IF(YEAR(B$2:B$194000)=H2,D$2:D$194000),0.95)
    I will ask the community for assistance.

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,562

    Re: Formula to filter out the year based on a list of dates

    As for the file attached to posts #4 and #6 I was able to get use the following LOGINV based array entered formula to obtain a 95th percentile:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    I was not successful in finding a way to get the pivot table on sheet2 to display a 95th percentile field.
    Attached Files Attached Files

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Formula to filter out the year based on a list of dates

    What number do you expect - for 2011 I get 17.77477 as the 95th percentile for a normal distribution?
    Last edited by xladept; 08-12-2017 at 11:04 AM. Reason: Recalc
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula to filter out the year based on a list of dates

    15000 rows is not a sample. If it's cut down to size, then it's feasible to see what's going wrong and correct it.

    Adjust the formulae to ignore the error. For example the MAX:

    =MAX(IF(NOT(ISERROR($E$2:$E$21)),IF(YEAR($A$2:$A$21)=$F2,$E$2:$E$21,"")))

    array entered.


    See sheet. How does this look?
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

+ 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. [SOLVED] filter between two dates (Month/Year) with Combobox
    By jhonyepv in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-21-2016, 11:33 PM
  2. Replies: 1
    Last Post: 04-20-2015, 12:11 PM
  3. Trying to make a filter list based on dates
    By siukingyiu in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 01:40 PM
  4. Need formula to change dates based on given year
    By kesmith2 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-27-2013, 06:46 AM
  5. [SOLVED] 1900 year date when filter column of dates
    By rz6657 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-03-2013, 12:18 PM
  6. Based on col dates create col of dates for the first day of that same month and year
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2011, 09:32 PM
  7. filter list on new sheet based on due dates
    By AdamK in forum Excel General
    Replies: 2
    Last Post: 09-15-2010, 04:53 PM

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