+ Reply to Thread
Results 1 to 10 of 10

Filter for active quarters in a Date Range

  1. #1
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Cork, Ireland
    MS-Off Ver
    Excel 365
    Posts
    149

    Filter for active quarters in a Date Range

    Can't figure how to approach this one so think I need some fresh eyes.

    If you see in attached example. I have a list of projects with Start & Finish dates.

    I want to be able to filter the projects for a specific Year and Qtr - but the twist is I want to see all projects ACTIVE during that Qtr.

    So, say a project started on 15/12/2021 and finished on 30/06/2022 - that project was active in Q4 2021, Q1 2022, and Q2 2022. So if I filter for any of those QTRs, that project should appear.

    Ideally I'd like to achieve this through Power Query but any ideas would be appreciated.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,989

    Re: Filter for active quarters in a Date Range

    So, I set up a lookup table:

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    M
    N
    6
    January Q1
    7
    February Q1
    8
    March Q1
    9
    April Q2
    10
    May Q2
    11
    June Q2
    12
    July Q3
    13
    August Q3
    14
    September Q3
    15
    October Q4
    16
    November Q4
    17
    December Q4
    Sheet: Sheet1

    and two reference cells:

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    I
    J
    6
    Q1
    2022
    Sheet: Sheet1

    Then I used this:

    =LET(q,FILTER(M6:M17,N6:N17=I6),s,DATE(J6,INDEX(MONTH(DATEVALUE(q&" 1")),1),1),f,DATE(J6,INDEX(MONTH(DATEVALUE(q&" 1")),3),31),FILTER(A6:C15,((B6:B15<=s)*(C6:C15>=s))+((B6:B15<=f)*(C6:C15>=f))))

    Alternatively, without the lookup table:

    =LET(s,DATE(J6,LOOKUP(I6,{"Q1","Q2","Q3","Q4"},{1,4,7,10}),1),f,DATE(J6,LOOKUP(I6,{"Q1","Q2","Q3","Q4"},{3,6,9,12}),31),FILTER(A6:C15,((B6:B15<=s)*(C6:C15>=s))+((B6:B15<=f)*(C6:C15>=f))))
    Attached Files Attached Files
    Last edited by AliGW; 10-14-2022 at 04:04 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,989

    Re: Filter for active quarters in a Date Range

    Seen, but no reply, not even a 'thank you for your time and effort'.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  4. #4
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Cork, Ireland
    MS-Off Ver
    Excel 365
    Posts
    149

    Re: Filter for active quarters in a Date Range

    Your time and effort is greatly appreciated - thank you very much for the example.

    You only posted about an hour ago and as my actual dataset is a lot more complex than the example I gave, I was trying to implement your suggestion on it before I came back to you, in case I wanted to clarify anything. I was not ghosting you, just needed a bit of time to digest the solution.

    I will leave the post active for the moment as I would like to see if anyone has any Power Query ideas.
    Last edited by AliGW; 10-14-2022 at 06:43 AM. Reason: Please DON'T quote unnecessarily!

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,989

    Re: Filter for active quarters in a Date Range

    If you want a PowerQuery solution, then you need to add this to the thread title for better visibility - I missed it completely in your opening post.

    In future, if you are going to take time testing a solution, at the very least drop a note to say this so that the helper knows. Thanks.

  6. #6
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Cork, Ireland
    MS-Off Ver
    Excel 365
    Posts
    149

    Re: Filter for active quarters in a Date Range

    Hi AliGW,

    I've been playing around with the solution you kindly provided and am delighted with it - I don't think I need PQ now but I do have one question:

    If you look at example attached. 3 of the items (highlighted red) are not showing in the Filter functions results and I can't seem to figure out why.

    Would really appreciate your thoughts?
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,990

    Re: Filter for active quarters in a Date Range

    Here are two possible solutions, both including the following:
    1. Make a second range T5:V8 that defines the quarters
    2. Populate the quarter being used to filter in T9:V9 using: =P5; =VLOOKUP(P5,T5:U8,2) and =VLOOKUP(P5,T5:V8,3) respectively
    3. Convert the range A5:C15 into an Excel table
    The first proposed solution shown in P6:R15 displays the filtered dates using:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that StartQtr is cell U9 and EndQtr is cell V9
    The second proposed solution adds a Filter column (D5:D15) to the original table. The Filter column is populated using: =AND([@[Start Date]]<=EndQtr,[@[End Date]]>=StartQtr)
    When TRUE is selected using the sort/filter down arrow in cell D5 the table is filtered.
    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.

  8. #8
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Cork, Ireland
    MS-Off Ver
    Excel 365
    Posts
    149
    Quote Originally Posted by JeteMc View Post
    Here are two possible solutions, both including the following:
    1. Make a second range T5:V8 that defines the quarters
    2. Populate the quarter being used to filter in T9:V9 using: =P5; =VLOOKUP(P5,T5:U8,2) and =VLOOKUP(P5,T5:V8,3) respectively
    3. Convert the range A5:C15 into an Excel table
    The first proposed solution shown in P6:R15 displays the filtered dates using:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that StartQtr is cell U9 and EndQtr is cell V9
    The second proposed solution adds a Filter column (D5:D15) to the original table. The Filter column is populated using: =AND([@[Start Date]]<=EndQtr,[@[End Date]]>=StartQtr)
    When TRUE is selected using the sort/filter down arrow in cell D5 the table is filtered.
    Let us know if you have any questions.
    Thanks so much JeteMc, i will try this out and let you know how it goes! Much appreciated.

  9. #9
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Cork, Ireland
    MS-Off Ver
    Excel 365
    Posts
    149

    Re: Filter for active quarters in a Date Range

    Hi JeteMc,

    I have tested your suggestions and the second option has worked brilliantly with my data!

    I've added the Filter column into the data (have also incorporated a month filter option using your Qtr technique) and then am able to show the results in another sheet using the FILTER function.

    Thanks so much for your help with this!

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,990

    Re: Filter for active quarters in a Date Range

    You're Welcome. Thank You for the feedback and for marking the thread as 'Solved'. I hope that you have a blessed day.

+ 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. Replies: 1
    Last Post: 01-31-2019, 02:24 AM
  2. Daily revenue recognition with start date and end date by quarters
    By shakeexcel in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-18-2014, 01:26 AM
  3. [SOLVED] Counting the quarters in a date range
    By mharry in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 04-02-2013, 12:47 PM
  4. Filter several pivot tables by one programmed date range filter in Excel 2003
    By olewka in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2011, 11:49 AM
  5. Excel 2007 : Date Function - Quarters
    By Phillydog in forum Excel General
    Replies: 1
    Last Post: 02-03-2011, 06:38 PM
  6. Macro Filter Active Range
    By ebbo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2010, 07:42 AM
  7. Filter range of only active cells???
    By malik641 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 09-06-2005, 10:05 AM

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