+ Reply to Thread
Results 1 to 16 of 16

Need help with COUNTIF (?) formula

  1. #1
    Registered User
    Join Date
    04-03-2018
    Location
    Detroit, MI
    MS-Off Ver
    Professional Plus 2016
    Posts
    20

    Need help with COUNTIF (?) formula

    Afternoon all,

    Looking for help writing a formula for a ledger spreadsheet that counts multiple entries for a single date (counts as 1 per date group) but only counts the entry if there is an associated time with the same row. I have gotten the COUTNIF function to work perfectly, but only counting multiple day entries as a single count.

    What I have currently:

    Please Login or Register  to view this content.
    2021-04-01 13_41_37-Time_Ledger_2021_v2 - Excel.png

    In the attached picture, The cells in orange (column C) will count as 1 day in my spreadsheet, but I am looking for only the top one to count as 1 because there is a time value associated with it (column H, in orange).

    I have tried variations of:

    Please Login or Register  to view this content.
    but it returns a decimal value instead of a whole number. Any help would be greatly appreciated!!!

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,364

    Re: Need help with COUNTIF (?) formula

    Please read the yellow banner at the top the page on how to attach an Excel file.

  3. #3
    Registered User
    Join Date
    04-03-2018
    Location
    Detroit, MI
    MS-Off Ver
    Professional Plus 2016
    Posts
    20

    Re: Need help with COUNTIF (?) formula

    Sample sheet attached. Formula is in cell C5. Thank you, I Appreciate the help!
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,791

    Re: Need help with COUNTIF (?) formula

    C5=SUM(IF(FREQUENCY(IF(C8:C100<>"",C8:C100),C8:C100),1))

    control+shift+enter

  5. #5
    Registered User
    Join Date
    04-03-2018
    Location
    Detroit, MI
    MS-Off Ver
    Professional Plus 2016
    Posts
    20

    Re: Need help with COUNTIF (?) formula

    Thank you for the quick response! After rereading my original post, I think my original description may have been confusing, my sincerest apologies. My current formula groups multiple rows with the same date and counts them as 1 and it looks like your suggested formula accomplishes the same thing.


    What I am looking for help with is writing a formula that will count a row that has a date in a cell in column C and in the same row an associated time in the cell in column H. The rows that have the same date in column C will still only count as 1. The intention is there will be multiple rows with entries with the same date with time logged for that day (count as 1 day worked). But, there will occasionally be an entry with a date, but no time associated - those days I do not want to count as a day worked - only count the entries with a date that have a time with them.

    Thank you all for looking!
    Last edited by AliGW; 04-02-2021 at 09:02 AM. Reason: PLEASE don't quote unnecessarily!

  6. #6
    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,444

    Re: Need help with COUNTIF (?) formula

    So where have you mocked up what you want? I can only see what you don't appear to want in the workbook. What is the RESULT (value) you are looking for and where should it appear?
    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.

  7. #7
    Registered User
    Join Date
    04-03-2018
    Location
    Detroit, MI
    MS-Off Ver
    Professional Plus 2016
    Posts
    20

    Re: Need help with COUNTIF (?) formula

    AliGW,

    Thank you for your help!


    In the attached sample workbook, there are 4 groups of dates listed (1-Apr-2021, 2-Apr-2021, 3-Apr-2021, and 4-Apr-2021). The formula in cell C5 returns a "4", as it is counting the number of days listed in the workbook. I am looking for it to return a "2" instead because while there are 4 days listed, there are only 2 days that have any time associated with them (listed in column H).
    Attached Files Attached Files

  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,444

    Re: Need help with COUNTIF (?) formula

    Try this:

    =SUM(IF(H8:H200<>"",1/COUNTIF(C8:C200, C8:C200), 0))

  9. #9
    Registered User
    Join Date
    04-03-2018
    Location
    Detroit, MI
    MS-Off Ver
    Professional Plus 2016
    Posts
    20

    Re: Need help with COUNTIF (?) formula

    AliGW,

    I appreciate the suggestion, we are definitely getting warmer! It does not quite work as expected though; with that formula, if there is only 1 entry for a given day with time associated with it, the result will include that day. If there are 2 entries for a given day, but only one of the entries has time associated with it, the result will reduce the count by 1.

    In the end, I am looking for at least 1 entry for any given date that includes time for that day to be added to the "Days Worked This Month" result (cell C5). For example: If there is one entry for 2-Apr-2021 with an associated time (column H), then it counts as 1; if there are 20 entries for 2-Apr-2021 but only 1 entry with associated time, then it still counts as 1; if there is 1 or more entries for 2-Apr-2021 but none have associated time with them, then it does not count at all.

  10. #10
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,791

    Re: Need help with COUNTIF (?) formula

    C5=SUM(IF(FREQUENCY(IF(ISNUMBER(H8:H200),C8:C200),C8:C200),1))

    Control+shift+enter

  11. #11
    Registered User
    Join Date
    05-29-2020
    Location
    Indiana, USA
    MS-Off Ver
    M365
    Posts
    27

    Thumbs up Re: Need help with COUNTIF (?) formula

    I know you can do it with an array, but this is one way of doing it.

    In Column A:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    C5:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    (-1 because I used 0 as false and it shows as a unique value)
    Attached Files Attached Files

  12. #12
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: Need help with COUNTIF (?) formula

    May be:

    =SUM(IF(H8:H200<>"",1/COUNTIFS(H8:H200,"<>",C8:C200,C8:C200),0))

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Quang PT

  13. #13
    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,444

    Re: Need help with COUNTIF (?) formula

    As the OP has MS365, there's no need to enter any formula as an array formula.

  14. #14
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: Need help with COUNTIF (?) formula

    It may be benefits for whom do not have MS365

  15. #15
    Registered User
    Join Date
    04-03-2018
    Location
    Detroit, MI
    MS-Off Ver
    Professional Plus 2016
    Posts
    20

    Re: Need help with COUNTIF (?) formula

    bebo021999,

    I tried your suggested formula and it appears to work perfectly for what I wanted, thank you!!!



    Thank you guys for your help!

  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,444

    Re: Need help with COUNTIF (?) formula

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

    Also, 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 helped.

+ 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] formula to identify the unique code after filtration using countif or other formula
    By felixpanganiban in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-27-2019, 01:25 PM
  2. [SOLVED] COUNTIF formula where part of the range reference needs to use the result of a formula
    By zookeepertx in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 11-09-2018, 05:39 PM
  3. Adding a COUNTIF function to an existing IF AND COUNTIF Formula...
    By Ourkid123uk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-24-2018, 10:09 AM
  4. Assistance with CountIF formula and additional formula conditions
    By solios in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-18-2016, 01:46 PM
  5. Faster if/countif formula for flagging uniques - countif too slow
    By Speshul in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-19-2015, 01:44 PM
  6. [SOLVED] =Subtotal(countif,Range); Subtotal and countif in 1 formula [SOLVED]
    By thomas.mapua in forum Excel General
    Replies: 5
    Last Post: 01-06-2012, 11:33 AM
  7. Adding a CountIF to a formula that is already Countif
    By Cmorgan in forum Excel General
    Replies: 4
    Last Post: 06-01-2011, 09:34 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