+ Reply to Thread
Results 1 to 14 of 14

COUNT formula selectively working?

  1. #1
    Registered User
    Join Date
    04-20-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    5

    COUNT formula selectively working?

    I made an attendance schedule for a nursery, it's supposed to allow me to check who is in what class depending on the month selected in the dropdown menus in A1/B1.
    Zoomed in table.png


    Then at the bottom is another table that counts how many kids are in each class, each day.

    For some reason whenever i select a date in the past, the COUNT formula in the bottom table stops returning values... except for Thursday and Friday - despite them having an identical formula to the other days.
    Zoomed in for August.png

    The formula is as follows
    =COUNT(FILTER(Attendance[Thursday], (Attendance[Thursday]=1) * SUBTOTAL(103, OFFSET(Attendance[Thursday], ROW(Attendance[Thursday])-MIN(ROW(Attendance[Thursday])),,1))))

    Can anyone see where i've gone wrong here?

    Attendance for Excel.xlsm

    (Also, if anyone has any ideas/templates on how i could streamline any of this process please share! I've worked so long on this sheet that i can't see anything anymore)
    Attached Images Attached Images

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,162

    Re: COUNT formula selectively working?

    The first thing that happened when I opened your file is that row 5 for A W was all errors because the DOB is text, not a valid date value. I don't know why your screenshot does not show the errors. The "07" is causing it to be interpreted as text. I removed the extra 0 in my version.

    bad date.jpg


    I am having trouble reverse engineering the formula you have in the bottom table. It seems overly complicated to simply return the number of kids in each class, each day. I would say the whole scheme is more complicated than necessary. You are coding the presence on each day from 1-3 depending on the class, but the class is already available in column F. I see you are using that to make the conditional formatting colors match the cell fill used for each class, but it's not necessary to use that information in formulas.

    I have created a copy of your sheet with the date correction and a new formula for the bottom table that appears to work. I did not take the time to break down your formula to figure out why it wasn't working.
    Attached Files Attached Files
    Last edited by 6StringJazzer; 08-13-2024 at 09:57 AM.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: COUNT formula selectively working?

    Quote Originally Posted by 6StringJazzer View Post
    I don't know why your screenshot does not show the errors.
    OP is in the UK so that's a valid date format as far as DATEDIF is concerned.
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: COUNT formula selectively working?

    Quote Originally Posted by Born2Excel View Post
    Can anyone see where i've gone wrong here?
    You're getting #NUM! errors where the DOB is after the date you select, which then breaks the FILTER function. I haven't verified, but I suspect changing the formula in E to:

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


    should fix it.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,162

    Re: COUNT formula selectively working?

    Quote Originally Posted by romperstomper View Post
    OP is in the UK so that's a valid date format as far as DATEDIF is concerned.
    Interesting. I did not know DATEDIF would do silent coercion of text.

  6. #6
    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. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,790

    Re: COUNT formula selectively working?

    What text is being coerced? All of the dates are valid dates - we use dd/mm/yyyy. Or am I misundarstanding your comment?
    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.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: COUNT formula selectively working?

    The DOB in row 5 is actually text.

  8. #8
    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. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,790

    Re: COUNT formula selectively working?

    None of the others are, though - was it that one date that was being referred to?

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: COUNT formula selectively working?

    Yes (Jeff did specify row 5 A to W )

  10. #10
    Registered User
    Join Date
    04-20-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    5

    Re: COUNT formula selectively working?

    Thanks, your version does seem to work!
    My previous formula was trying to prevent excel from counting rows that were filtered out in Column N. But your formula does this much more succinctly.

  11. #11
    Registered User
    Join Date
    04-20-2020
    Location
    London
    MS-Off Ver
    365
    Posts
    5

    Re: COUNT formula selectively working?

    Quote Originally Posted by 6StringJazzer View Post
    The first thing that happened when I opened your file is that row 5 for A W was all errors because the DOB is text, not a valid date value. I don't know why your screenshot does not show the errors. The "07" is causing it to be interpreted as text. I removed the extra 0 in my version.

    Attachment 876843


    I am having trouble reverse engineering the formula you have in the bottom table. It seems overly complicated to simply return the number of kids in each class, each day. I would say the whole scheme is more complicated than necessary. You are coding the presence on each day from 1-3 depending on the class, but the class is already available in column F. I see you are using that to make the conditional formatting colors match the cell fill used for each class, but it's not necessary to use that information in formulas.

    I have created a copy of your sheet with the date correction and a new formula for the bottom table that appears to work. I did not take the time to break down your formula to figure out why it wasn't working.
    Thanks this worked, and yes as someone mentioned, it's because i use the british date format

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,162

    Re: COUNT formula selectively working?

    Quote Originally Posted by romperstomper View Post
    Yes (Jeff did specify row 5 A to W )
    Not A to W, but "A W" is the child's name

  13. #13
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,056

    Re: COUNT formula selectively working?

    Ahh! That makes sense.

  14. #14
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: COUNT formula selectively working?

    By the way, your formula for Age and Class could be shortened to:

    Age in E4: =FLOOR(YEARFRAC([@DOB],DATEVALUE($A$1&$B$1)),0.5)
    Class in F4: =LOOKUP([@Age],{0,1.5,3},{"Lambs","Builders","Beavers"})

+ 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] Count Days Formula Not Working
    By aig_s in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-25-2023, 08:51 AM
  2. [SOLVED] Help witth formula to count # Emp's currently working on a job
    By TGR897 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 07-03-2023, 12:47 AM
  3. Replies: 6
    Last Post: 01-06-2020, 09:56 PM
  4. Count merge cells formula (VBA) is not working
    By shiva_raj in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2019, 06:58 AM
  5. Count working day with formula
    By nickh1981 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-12-2015, 09:03 PM
  6. Count Formula not working Excel Mac 2011
    By jimmerdean in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-20-2012, 04:34 PM
  7. Vlookup formula responds selectively for some and not all values
    By Amarilis Abreu in forum Excel General
    Replies: 4
    Last Post: 08-18-2009, 04:52 PM

Tags for this Thread

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