+ Reply to Thread
Results 1 to 18 of 18

Array formula counting empty cells as zero

  1. #1
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    990

    Array formula counting empty cells as zero

    Hi. I have this array formula

    =MAX(FREQUENCY(IF(ALL!$I$2:$I$5375="League",IF(ALL!$E$2:$E$5375="H",IF(ALL!$L$2:$L$5375=0,ROW(ALL!$L$2:$L$5375)))),IF(ALL!$I$2:$I$5375="League",IF(ALL!$E$2:$E$5375="H",IF(ALL!$L$2:$L$5375>0,ROW(ALL!$L$2:$L$5375))))))

    which works fine up to a point. It's looking for the longest sequence of zero's. However the formula is counting blank cells as zero's so as there is more data to be added each week and there are more rows left to be filled then the formula is counting these empty cells as zero's which is some cases produces a false result. To stop this happening I have to limit the range of the formula to the last row where data has been entered. Is there a way round this or does it mean every week I have to update the array formula? Many thanks.
    Last edited by Marvo; 12-04-2020 at 01:58 PM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,052

    Re: Array formula counting empty cells as zero

    Probably the same issue as before. Can you post a sheet, and indicate where the problem is to be found. It's very hard to visualise a formula like that!!
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    990

    Re: Array formula counting empty cells as zero

    Sorry Glenn. Its within the array formulas in column C. I want the array to go to the final game of the season which is ROW 5400 on the ALL page which is fine when you're looking for consecutive data but not so good when you're looking for the gaps in between. So it's the LONGEST RUNS WITHOUT that are the problem because the formula counts the blank cells if I set the array at row 5400. If you can have a look at C120 & C121 and if they can be fixed I can work out the rest from there.
    Attached Files Attached Files

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Array formula counting empty cells as zero

    Please try

    =MAX(FREQUENCY(IF(ALL!$I$2:$I$5400="League",IF(ALL!$L$2:$L$5400<>"",IF(ALL!$L$2:$L$5400=0,ROW(ALL!$L$2:$L$5400)))),(IF(ALL!$I$2:$I$5400="League",IF(ALL!$L$2:$L$5400>0,ROW(ALL!$L$2:$L$5400))))))

  5. #5
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    990

    Re: Array formula counting empty cells as zero

    Yep that works Bo-Ry. so basically I've just got to add the extra if segment to my array formulas. Great. Many thanks.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,052

    Re: Array formula counting empty cells as zero

    I would be tempted to go for Named ranges at this point. These adjust automatically to suit the length of your data.

    For the competion type (Comp) I used:
    ALL!$I$2:INDEX(ALL!$I$2:$I$20000,SUMPRODUCT(--(LEN(ALL!$J$2:$J$20000)>0)))

    the red bit ensures that it only goes down the competition column to the last result.

    For the result (WDL), I used:
    =ALL!$J$2:INDEX(ALL!$J$2:$J$20000,SUMPRODUCT(--(LEN(ALL!$J$2:$J$20000)>0)))

    for scores home and away, set up named ranges based on WDL, as you don't want them to look at rows where no result is in.

    The formula (C120) then becomes:
    =MAX(FREQUENCY(IF(Comp="League",IF(WDL<>"W",ROW(WDL))),(IF(Comp="League",IF(WDL="W",ROW(WDL))))))

    I am leaving now. Can you add the other named ranges? If you have issues, I'll be back tomorrow. Incidentally, you have a fair number of dead Named Ranges (CTRL-F3). I suggest you kill the ones that are giving errors.
    Attached Files Attached Files

  7. #7
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    990

    Re: Array formula counting empty cells as zero

    Hi Glenn, that does seem like a good idea but I'm not sure how to set about doing it. I've used named ranges before many, many years ago but I cant recall how to set them up. The dead ranges you mention are still alive, they connect to other pages of the workbook I didn't include to make the example smaller. I'll have a look at it, see if I can make it work. Many thanks.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,052

    Re: Array formula counting empty cells as zero

    Adapt the formula for your new range in a cell. Copy.

    CTRL-F3.

    New

    Paste

    Done

    check it (sometimes they get confused and slip to whole row/column references when copy pasting, but usually only if there are non-$'d ranges, which you won't have).

    Run.

  9. #9
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    990

    Re: Array formula counting empty cells as zero

    Sorry Glenn, I tried but I couldn't do it. Managed to complete C113-C115 and C118-C120 as they were yours in Name Manger but couldn't set my own up for home or away (Column E) or goals scored (K) or conceded (L) whatever I tried, copying what you had done, trying stuff off my own back, no success, kept giving me a return of #NA.

    I've attached the full workbook, you will see I have a "list" page for name manager, probably don't need it.
    Attached Files Attached Files

  10. #10
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Array formula counting empty cells as zero

    @Glenn
    For the competion type (Comp) I used:
    ALL!$I$2:INDEX(ALL!$I$2:$I$20000,SUMPRODUCT(--(LEN(ALL!$J$2:$J$20000)>0)))
    it is working but what reason to use it instand of COUNTIF
    ALL!$I$2:INDEX(ALL!$I$2:$I$20000,COUNTIF(ALL!$J$2:$J$20000;"?*"))
    For my opinion the part =COUNTIF(ALL!$J$2:$J$20000;"?*") must be calculated in separate cell for best performance.

    For this example B112 =COUNTIF(ALL!J:J,"?*")+1
    Comp =ALL!$I$2:INDEX(ALL!$I:$I,Summary!$B$112)
    WDL==ALL!$J$2:INDEX(ALL!$J:$J,Summary!$B$112)
    Attached Files Attached Files

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,052

    Re: Array formula counting empty cells as zero

    The reason is simple. I didn't think of it.
    Last edited by Glenn Kennedy; 12-05-2020 at 04:19 AM.

  12. #12
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    990

    Re: Array formula counting empty cells as zero

    So, I've got up, all ready to spend hours on this to get it right and now I'm totally confused?

    The 5368 result in B112 in the example by BMV is how many rows there are?

    The total amount of games played is 5367.

    What am I looking at?

    On the ALL sheet, in cell R5350 will always be the total amount of games played. Wouldn't using this cell in the formula make things easier? If I need it to result in 5368 I could always +1 it?
    Last edited by Marvo; 12-05-2020 at 05:10 AM.

  13. #13
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    990

    Re: Array formula counting empty cells as zero

    I think I've got it now guys. Will be back if I hit a snag but fingers crossed.

  14. #14
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Array formula counting empty cells as zero

    +1 because i ise whole column for index and count non zerro cells. Enter header and +1 can be deleted. However it is right for table from row 1 .

  15. #15
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    990

    Re: Array formula counting empty cells as zero

    Okay guys, all done. Thank you so much for all the help.

    Completed workbook attached. Any advice always appreciated.
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Array formula counting empty cells as zero

    I would remove the solved tag from this thread, if I were you.
    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.

  17. #17
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    990

    Re: Array formula counting empty cells as zero

    I think we're done Ali, I wouldn't want to hog all the valuable time of your contributors. I'm very happy with the outcome and I'm learning, just very slowly.

  18. #18
    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,830

    Re: Array formula counting empty cells as zero

    Oh, I see - I thought you needed some more help.

    Don't worry - nobody will let you hog them!!!

+ 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] Not counting cells when empty
    By andynw1 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-25-2020, 01:22 PM
  2. [SOLVED] counting cells with an array formula in
    By swfarm in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-17-2019, 05:26 PM
  3. Replies: 8
    Last Post: 07-30-2018, 07:06 PM
  4. [SOLVED] Average array formula to conitinue calculating even if one of cells or many are empty
    By wellous in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-28-2015, 12:17 PM
  5. [SOLVED] Counting blank cells that are empty buy contain a formula...
    By Losguapos1 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-29-2014, 11:15 AM
  6. counting empty cells
    By Davycc in forum Excel General
    Replies: 5
    Last Post: 04-07-2011, 12:00 PM
  7. Sumproduct or array formula for counting criteria of sum of cells
    By jasoncw in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-09-2007, 03:09 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