+ Reply to Thread
Results 1 to 13 of 13

Between 2 Dates - Adding to my existing formula.

  1. #1
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Between 2 Dates - Adding to my existing formula.

    Hi Guys,

    Here an an existing formula I am using which performs a count of user ID numbers in column A (excluding duplicates) if the date in column G contains a user profile expiry date greater than today.


    {=SUM(--(FREQUENCY(IF(A:A<>"",IF(G:G>TODAY(),MATCH(A:A,A:A,0))),ROW(A:A)-ROW(A1)+1)>0))}

    The formula works perfectly fine however at present it checks if the date in column G is greater than today. I need to change the formula so it checks if the date in column G is between today and 90 days time instead.

    Any help would be greatly appreciated.

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Between 2 Dates - Adding to my existing formula.

    {=sum(--(frequency(if(a:a<>"",if((g:g>today())*(g:g<90+today()),match(a:a,a:a,0))),row(a:a)-row(a1)+1)>0))}

  3. #3
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Re: Between 2 Dates - Adding to my existing formula.

    Quote Originally Posted by tim201110 View Post
    {=sum(--(frequency(if(a:a<>"",if((g:g>today())*(g:g<90+today()),match(a:a,a:a,0))),row(a:a)-row(a1)+1)>0))}
    Tim201110 - Thank you sir. That worked perfectly.

    On a side note, in your humble opinion, can the formula be rationalized/made more efficient as it does seem quite long.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,792

    Re: Between 2 Dates - Adding to my existing formula.

    That is not a long formula by any stretch of the imagination!!! :D
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Re: Between 2 Dates - Adding to my existing formula.

    I need to adapt this formula.

    The existing formula I am using performs a count of unique user ID numbers in column A (excluding duplicates) if the date in column J contains a user profile expiry date is within 180 days of age.


    =SUM(--(FREQUENCY(IF(Sheet1!A:A<>"",IF(Sheet1!J:J>TODAY()-180,MATCH(Sheet1!A:A,Sheet1!A:A,0))),ROW(Sheet1!A:A)-ROW(Sheet1!A2)+1)>0))


    I'll provide a visual illustration of my scenario. As you can see I have 3 users (see User ID column A). I need a formula which performs a total count of User ID (excluding duplicates) by looking at the most recent login date only and checking if it's within the last 180 days regardless of the values in column R.

    So the result of the correct formula based on the table below would calculate that only 2 user ID's have logged in within the last 180 days.


    Column A Column J Column R
    User ID Last Login Date User Role
    123 05/11/2018 Standard
    123 01/04/2018 Super
    123 02/04/2016 Test
    456 05/08/2018 Super
    456 01/11/2018 Test
    789 09/09/2017 Test
    789 23/01/2017 Super
    Last edited by makaveeti; 11-06-2018 at 12:38 PM.

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

    Re: Between 2 Dates - Adding to my existing formula.

    I believe that the formula (if array entered*) works. Given that this question was posted on Nov. 6th 2018 the only date that would have been within the past 180 days was 5/11/2018, (5/8/2018 was 182 days in the past) so the formula should, and does, return 1.
    *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.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  7. #7
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Re: Between 2 Dates - Adding to my existing formula.

    Apologies. I am using the formula with curly braces (forgot to reference that in my post). The Date format I am using is DDMMYYYY

    The formula works in that it does return a value but not the correct one. It counts the number of user ID occurances including duplicates instead of counting unique user ID's. I need the formula adapting to count unique user IDs only.

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

    Re: Between 2 Dates - Adding to my existing formula.

    It may help us, in our effort to help you, if you could upload a sample showing when the formula fails to return the correct value.
    To upload a sample workbook (not a picture or pasted copy) click on the GO ADVANCED button below the Quick Reply window and then scroll down to Manage Attachments to open the upload window.
    Let us know if you have any questions.

  9. #9
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Re: Between 2 Dates - Adding to my existing formula.

    As requested I've attached an excel file.

    The formula is on sheet 1. Raw data is on sheet 2.

    As you can see from sheet 2, there are 3 occurances (by 2 users) of user(s) who logged in during the last 180 days.


    123 05/11/2018 Standard
    456 05/08/2018 Super
    456 01/11/2018 Test

    The formula returns a value of 3. I would like it to return a value of 2 since there are only 2 users who logged in during the last 180 days.
    Attached Files Attached Files
    Last edited by makaveeti; 11-14-2018 at 09:39 AM.

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

    Re: Between 2 Dates - Adding to my existing formula.

    I was not able to evaluate the formula due to the whole column references, however when I used the range 2:10 (as modeled in cell B2) I got the expected result of 2.
    As you may need the range on sheet 2 to be expandable you might consider converting to a table and using structured references (as modeled in B3) for your formula.
    Range formula*:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Structured reference formula*:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    *Denotes an array entered formula.
    Let us know if you have any questions.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Re: Between 2 Dates - Adding to my existing formula.

    Thank you very much for your reply.

    I did a sanity check by counting manually and it looks like the formula also counts values in row A (labels).

    Using a specific column reference returns the correct value however I need the range to be expandable so rather than use a table like you have suggested I simply put in a higher range which I know the column will not exceed i.e. A2:A5000. This works and also returns the correct value.

    I think this is what threw me off. My original formula was correct and did work. It was just the column range that was the issue.

  12. #12
    Forum Contributor
    Join Date
    07-25-2017
    Location
    UK
    MS-Off Ver
    Office 365 Excel Version 2202 Build 16
    Posts
    184

    Re: Between 2 Dates - Adding to my existing formula.

    . double post

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

    Re: Between 2 Dates - Adding to my existing formula.

    You're Welcome and glad that you got a solution that works for you. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. 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: 3
    Last Post: 01-13-2016, 12:05 PM
  2. adding to existing formula
    By jryoung91 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-02-2015, 09:39 AM
  3. Adding to an existing formula !!!!!!!!!
    By hlb129 in forum Excel General
    Replies: 3
    Last Post: 02-10-2015, 08:02 AM
  4. Adding another formula to an existing one
    By JakeMann in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-14-2014, 08:22 AM
  5. Adding to an Existing Formula
    By jcl6543 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-05-2014, 12:58 AM
  6. adding to existing formula
    By wwoody in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-17-2013, 03:25 AM
  7. Adding to 2 existing formula
    By cmackay1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-14-2012, 05:14 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