+ Reply to Thread
Results 1 to 29 of 29

Filter Dates

  1. #1
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Filter Dates

    Hey all--

    I have a coding question of how to filter with dates--

    My column A is a list of dates--- my column B is a list of numbers

    I need to know when Column B = 5 for 4 weeks in a row.

    Any help would be fantastic--thanks.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Filtering Dates

    Hi,

    this requires some more info, for example

    - are you looking for VBA or formulaic solution?
    - what exactly do you want to return when column B = 5 four weeks in a row? The four dates? The first date?
    - what do you want to happen when there are several instances of a 5 four weeks in a row?
    - is the data sorted by date?

    etc. So, ...

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  3. #3
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filtering Dates

    formula form would be easiest i believe--

    If the result would return the span of time of the successful 4 weeks in a row that would be best--

    if there are several instances if it could display each span that the instance occurs

    the date is sorted by date

    i will supply the dummy sheet if you still think it woudl help
    Last edited by teylyn; 01-03-2010 at 04:13 PM. Reason: deleted spurious quote

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Filtering Dates

    i will supply the dummy sheet if you still think it woudl help
    It would! Especially with regards to this:
    If the result would return the span of time of the successful 4 weeks in a row that would be best--
    How would you expect that to look? Please mock up an example.

    Oh, and please do not quote whole posts! Use the Quick Reply box or the Post Reply button instead of the Quote button.

    cheers

  5. #5
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    thanks so much for the help!

    and sorry bout the quote!
    Attached Files Attached Files

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Filter Dates

    is this from your workbook
    12/12/2004 to 3/1/2005
    what you actually want to display? As a text string?

    Also, is the data sample representative of your real data? A lot of the "dates" are actually text and need to be cleaned up to be consistent.

  7. #7
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Filter Dates

    I'm not quite sure this can be done with a formula. At least it would require a number of helper columns. would that work for you?

    Or maybe you could explain the bigger picture and detail what you want to achieve, so maybe there is something more obvious and simpler at hand.

    This seems to be quite focussed on the specific situation, and in the overall concept might be solved quite differently.

  8. #8
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    ok--so here is the actual file

    the actual problem is this:

    when column C is within 10% of column B for four days in a row.

    If it is more than four days in a row show all the dates until the 10% rule is broken, then continue to search after that date for the same thing.

    The only thing I need is the dates of when this is because we need to physically look at these dates on another program. We will be looking at twenty years worth of data so this would be very helpful.

    Thanks in advance and let me know anything you need. Whatever you think is the easiest way to do this just let me know.

  9. #9
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Filter Dates

    ok--so here is the actual file
    did you mean to attach a file?

  10. #10
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    sure did! sorry about that.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    if anyone can help do this i will be willing to shoot you 25$ through paypal-- i really need this done before a meeting. Thanks

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Filter Dates

    Maybe like this:
    Please Login or Register  to view this content.
    For formula in H5 and down is =SUMPRODUCT( --(ABS(C2:C5 / B2:B5 - 1) <=10%) ) = 4

    Then filter col H on TRUE.
    Last edited by shg; 01-09-2010 at 04:13 PM.
    Entia non sunt multiplicanda sine necessitate

  13. #13
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    SHG--Ty for the help-- the problem has changed to just be column C needs to be within 10% of eachother for AT LEAST 4 days in a row. No maximum number of days in a row. What is your email for paypal? Thanks again

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Filter Dates

    column C needs to be within 10% of eachother for AT LEAST 4 days in a row
    What does that mean? The last 4 values within 10% of the average of those values, or the max of the last 4 values not greater than 110% of the min, or ...?
    What is your email for paypal?
    That's very kind; please give it to your favorite charity.

  15. #15
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    Whatever the starting number is of the chain, the chain lasts until the number reaches greater than 10% of the starting number. It can be above or below it, just needs to be out of range of 10% of the starting number. Once that chain ends it will look for new starting numbers that have a minimum of 4 in a row within 10%.

    That will be done, and if you would rather it be donated to your charity of choice just name it.

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Filter Dates

    In H5, try =SUMPRODUCT( --(ABS(C3:C5 / B3 - 1) <=10%) ) = 3 and see if that gives the result you want.

  17. #17
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    still offering 25$ to anyone who can help.

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Filter Dates

    I take it the formula does not do what you want?

    How about posting an example?

  19. #19
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    oo sorry SNG that was my mistake. I added the post to my favorites and didn't even see it went to two pages!

    unfortunately it still was not what i was looking for.

    the problem is no longer effected by column B

    . It is only Column C that needs to have the math.

    for example.

    if column C starts at
    66
    63
    65
    68
    59

    the results would filter out the 59 because it became more than 10% away from the 66.

    once it ends the chain it needs to continue at the next number to find results that are within 10% of it--- the minimum must be 4 in a row.

  20. #20
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Filter Dates

    What if the column were:

    66
    63
    65
    68
    59
    59
    59
    59
    59

  21. #21
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    good question SHG. I think the best result would look like this:

    13-5-09 to 17-5-09
    18-5-09 to 23-5-09

    so knowing the dates of when the chains begin and end would be best for results. thanks again

  22. #22
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Filter Dates

    See if this is the correct logic.
    Attached Files Attached Files

  23. #23
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    it is looking very close SHG, or maybe it is correct but i am seeing it wrong.

    Some of the numbers in red I think should still be in a sequence, and some numbers in white should break the sequence searching for a new one.

    For example,
    the top four numbers were

    100
    103
    96
    90

    Those four should be displayed because the 3 numbers after 100 were all within 10% of 100. Unless it is <10< and not equal to.

    But there seemed to be more cases like that where a chain should have been identified or stopped.

    I really appreciate your constant help on this--

  24. #24
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Filter Dates

    rdubya, the numbers in the cells are random -- look at the formula. When you opened the workbook, it recalculated them, so the coloring is meaningless. Press F9 to generate a new set of numbers, then press the button, then look.

    Or enter your own numbers manually.

    EDIT: BTW, the code is hideous -- don't look at that

  25. #25
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    Ok seems to work! How would the filtering work with the colors? Can't thank you enough SHG.

  26. #26
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Filter Dates

    Just change the code to hide the rows instead of coloring them red. I'll do that when you're certain it's correct -- last bite of the apple.

  27. #27
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    Yup every instance I tried seemed to be correct.

  28. #28
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Filter Dates

    Replace the code that's in there with this:
    Please Login or Register  to view this content.

  29. #29
    Registered User
    Join Date
    05-30-2007
    Posts
    43

    Re: Filter Dates

    hey SHG

    just waiting to hear back from the boss--just wanted to thank you again.

+ 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