+ Reply to Thread
Results 1 to 26 of 26

Number of different dates based on multiple criteria

  1. #1
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Number of different dates based on multiple criteria

    Hi,

    I am looking for the following formula:

    In sheet1, column "A", I have a list of different names. Those names are not unique. In sheet1, column "B", I have a list of dates. Those dates are also not unique and
    a same name can have the same dates and different dates.
    In sheet2, column "A", I have a list of unique names from Sheet1, column "A". Now, I would like to have in sheet2, column "B", for each name of sheet1, column "A", how different dates they are for
    every name.

    Example in sheet1 John has as dates, 01/01 , 02/02, 02/02, 03/03, 04/04/, 04/04. John has 4 different dates in 6 different rows. I would like to have in sheet2, column "B", next John "4"

    Thank you for your help,

    Daniel

  2. #2
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.
    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.

  3. #3
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: Number of different dates based on multiple criteria

    a pivottable, with a data model, is a good tool for that.
    Otherwise an array formula ...
    Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

  4. #4
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    Please find here the file

    Daniel
    Attached Files Attached Files

  5. #5
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    Please confirm that you are using Excel 2016 and not MS365 - if you have upgraded, this will be easier.

  6. #6
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    Yes I am using Excel 2016 and Excel 2019

  7. #7
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    And does this particular issue need to work on Excel 2016?

  8. #8
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    Try this:

    =SUM(IF(A2=Sheet1!$A$2:$A$16,1/(COUNTIFS(Sheet1!$A$2:$A$16,A2,Sheet1!$B$2:$B$16,Sheet1!$B$2:$B$16)),0))

  9. #9
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    Yes.
    I am using Office 2016 at office.At home I have Office 2019 but I am only copying the file from office to home.

  10. #10
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    See post #8.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    Thank you
    But the formula is not accepted by Excel. Message :"There is a problem with the formula"
    Last edited by AliGW; 11-28-2021 at 06:42 AM. Reason: PLEASE don't quote unnecessarily!

  12. #12
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    That's because you need to change commas to semi-colons for your locale. Look at the attachment to post #10.

    If that takes care of your original question, please select 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 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.

  13. #13
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    Hi Aligw,

    Thanks so much for your patience and help

  14. #14
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    Please mark as solved, etc., as requested in post #12.

    You're welcome!

  15. #15
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    Sorry to come back.

    I have tried in my Excel file but it doesn't work. I copied it to cell B2 and did a copy paste. But it doesn't work. See file attached.
    Attached Files Attached Files

  16. #16
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    Remove the @ signs before copying down.

    Change this:

    =SUM(IF(A2=@Sheet1!$A$2:$A$16,1/(COUNTIFS(Sheet1!$A$2:$A$16,A2,Sheet1!$B$2:$B$16,@Sheet1!$B$2:$B$16)),0))

    to this:

    =SUM(IF(A2=Sheet1!$A$2:$A$16,1/(COUNTIFS(Sheet1!$A$2:$A$16,A2,Sheet1!$B$2:$B$16,Sheet1!$B$2:$B$16)),0))

    AliGW on MS365 Insider (Windows) 64 bit
    A
    B
    C
    1
    Unique name Number of different dates
    2
    Adam
    1
    =SUM(IF(A2=@Sheet1!$A$2:$A$16,1/(COUNTIFS(Sheet1!$A$2:$A$16,A2,Sheet1!$B$2:$B$16,@Sheet1!$B$2:$B$16)),0))
    Sheet: Sheet2

    If this doesn't work, try entering the formula as an array formula before copying down (CTRL+SHIFT+ENTER).
    Last edited by AliGW; 11-28-2021 at 07:21 AM. Reason: Typo fixed

  17. #17
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    Is this resolved now?

  18. #18
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    Sorry but still no luck

  19. #19
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    Did you try with CSE?

    The formula works on older versions of Excel. There is no reason why it should not work for you if entered correctly. This is user error, I am afraid, so very difficult to resolve for you.

    AliGW on MS365 Insider (Windows) 64 bit
    A
    B
    C
    D
    1
    Unique name Number of different dates
    AliGW
    2
    Adam
    1
    3
    Daniel: =SUM(IF(A2=@Sheet1!$A$2:$A$16,1/(COUNTIFS(Sheet1!$A$2:$A$16,A2,Sheet1!$B$2:$B$16,@Sheet1!$B$2:$B$16)),0))
    3
    Sam
    0
    3
    AliGW: =SUM(IF(A2=Sheet1!$A$2:$A$16,1/(COUNTIFS(Sheet1!$A$2:$A$16,A2,Sheet1!$B$2:$B$16,Sheet1!$B$2:$B$16)),0))
    4
    Dan
    0
    2
    5
    John
    0
    1
    6
    Mike
    0
    1
    Sheet: Sheet2

    In French:

    =SOMME(SI(A2=Sheet1!$A$2:$A$16;1/(NB.SI.ENS(Sheet1!$A$2:$A$16;A2;Sheet1!$B$2:$B$16;Sheet1!$B$2:$B$16));0))
    Last edited by AliGW; 11-28-2021 at 07:45 AM.

  20. #20
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    Ok. Thank you. I will try to figure out what's wrong. And thank you for your time

  21. #21
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    No worries - let us know how you get on.

  22. #22
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    It works now with the sample dates file. I tried in my main file and after entering the formula ( and of course having changed the sheet names and the cells ), Excel asks me to update the values from a sheet. I didn't have this message with the "dates" file;

  23. #23
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    In that case someting is NOT right with your sheet names. Check these carefully - Excel doesn't recognise at least one of them and is telling you to open the workbook where it is found. Make sure it is spelt correctly. I would set ranges by selecting them rather than by changing them manually, which is prone to user error.

  24. #24
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    It works now with my main file. Thanks so much for your help.
    May I ask you another help. I have written a complicated and slow macro to find out for every name, his last date . I think that this could also be resolved with a formula
    See attached file ( sheet2, column"C")
    Thanks in advance for your help.
    Attached Files Attached Files

  25. #25
    Forum Contributor
    Join Date
    10-02-2021
    Location
    Belgium
    MS-Off Ver
    Excel 2019
    Posts
    180

    Re: Number of different dates based on multiple criteria

    I found it:

    =MAX(IF(Sheet1!$A$2:$A$20=A3;Sheet1!$B$2:$B$20)) with CSE

  26. #26
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,434

    Re: Number of different dates based on multiple criteria

    In future, please start a new thread fir each separate query.

+ 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: 09-22-2021, 05:16 PM
  2. [SOLVED] Count the number of times a data appear based on multiple criteria between 2 dates
    By lati2008 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-22-2021, 03:53 PM
  3. Replies: 2
    Last Post: 12-27-2020, 04:10 AM
  4. count number of unique dates based on criteria
    By SammyN in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-25-2020, 07:21 AM
  5. Replies: 7
    Last Post: 04-30-2016, 03:20 AM
  6. Replies: 0
    Last Post: 01-31-2014, 07:39 AM
  7. Calculate number of departures between dates based on multiple criteria
    By IndigoIrish in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-18-2012, 03:22 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