+ Reply to Thread
Results 1 to 13 of 13

Counting formula is currently including blank cells and outputting " " because of this

  1. #1
    Registered User
    Join Date
    03-27-2018
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    76

    Angry Counting formula is currently including blank cells and outputting " " because of this

    Hello, I have a formula that finds the most common value in a row (we will call the most common value x). I then use the COUNTIF formula to count the number of occurrences of the value x.

    However, My table is 9 rows deep, and 100 columns long. And the data in this table is from other areas of the worksheet, thus all cells in the table have formula in.

    My problem is that the formula to find x, counts the blank cells. This means that x is always blank.

    eg.

    a, a, b, " " , " ", " " - instead of saying x is a because its the only value appearing twice, the formula says the most common value is " " and that it appears three times.



    Here is the formula to find x:

    =IFERROR((INDEX($B13:$L13,AGGREGATE(15,6,COLUMN($B$13:$L$13)-1/(COUNTIF($B13:$L13,$B13:$L13)=MAX(INDEX(COUNTIF($B13:$L13,$B13:$L13),))*(COUNTIF($M13:M13,$B13:$L13)=0)),COLUMN(A1)))),"")

    Again, It counts the blank cells because they have formula in. Anyway to stop it counting these cells. Thanks

    M is a helper column which is a series of 'x's.



    edit: i tried to include an example workbook but it stopped working all together. really struggling with this.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Counting formula is currently including blank cells and outputting " " because of this

    Attaching files:

    Use the Go Advanced option at the bottom of the page then scroll down to Manage Attachments as the "paperclip" method does not work on this forum.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    03-27-2018
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    76

    Re: Counting formula is currently including blank cells and outputting " " because of this

    Sorry, I was meaning that the formula itself stopped working. I couldnt get it to work to even return the blanks in the example workbook.

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

    Re: Counting formula is currently including blank cells and outputting " " because of this

    Where is the workbook?
    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
    Registered User
    Join Date
    03-27-2018
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    76

    Re: Counting formula is currently including blank cells and outputting " " because of this

    Ok, this is the workbook, but its playing up.

    It seems to be a very delicate formula if thats even such a thing as now I cant get it right again. Ive even re-done it. Also, my actual file doesnt have 0's in the tabel, its just blanks - i dont know how to make the cells blank in the example whilsyt having a formula in them
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Counting formula is currently including blank cells and outputting " " because of this

    ....

    sorry I've just seen your attachment
    Last edited by canapone; 11-21-2018 at 09:25 AM.
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  7. #7
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Counting formula is currently including blank cells and outputting " " because of this

    Hi Again

    in N15 to be copied across

    =IFERROR(INDEX($B15:$L15,AGGREGATE(15,6,COLUMN($B:$L)-1/((COUNTIFS($B15:$L15,$B15:$L15,$B15:$L15,"<>0")=MAX(INDEX(COUNTIFS($B15:$L15,$B15:$L15,$B15:$L15,"<>0"),)))*(COUNTIF($M15:M15,$B15:$L15)=0)),1)),"")


    Hope that helps
    Attached Files Attached Files

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

    Re: Counting formula is currently including blank cells and outputting " " because of this

    I amended your lower table to include formula blanks.

    An alternative, array formula in H15, copied across and down:

    =IFERROR(INDEX($B15:$L15,MODE(IF(B15:L15<>"",IF(COUNTIF($M15:M15,$B15:$L15)=0,MATCH($B15:$L15,$B15:$L15,0)+{0;0})))),"")

    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 11-21-2018 at 10:18 AM.
    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

  9. #9
    Registered User
    Join Date
    03-27-2018
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    76

    Re: Counting formula is currently including blank cells and outputting " " because of this

    This is a picture of my actual workbook and the issues are highlighted.

    Hi Glen, I will try your strategy now.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Counting formula is currently including blank cells and outputting " " because of this

    Hi All

    I've udjusted one of the conditions of countifs (not <>0, but >A)

    =IFERROR(INDEX($B15:$L15,AGGREGATE(15,6,COLUMN($B:$L)-1/((COUNTIFS($B15:$L15,$B15:$L15,$B15:$L15,">"&"A")=MAX(INDEX(COUNTIFS($B15:$L15,$B15:$L15,$B15:$L15,">"&"A"),)))*(COUNTIF($M15:M15,$B15:$L15)=0)),1)),"")

    I hope it could be of some help

  11. #11
    Registered User
    Join Date
    03-27-2018
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    76

    Re: Counting formula is currently including blank cells and outputting " " because of this

    Perfect! Works great thank you.

    I have added reputation to you both.

    Is it possible to adjust Glenn's formula so that it does the exact same thing but whilst looking at the whole array rather than just one row?

  12. #12
    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,023

    Re: Counting formula is currently including blank cells and outputting " " because of this

    Hi. there is a $ error in my formula:

    =IFERROR(INDEX($B15:$L15,MODE(IF($B15:$L15<>"",IF(COUNTIF($M15:M15,$B15:$L15)=0,MATCH($B15:$L15,$B15:$L15,0)+{0;0})))),"")

  13. #13
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Counting formula is currently including blank cells and outputting " " because of this

    Hi All

    in the attachment I'm exploiting column M as helper column in order to copy formulas toward right

    In N15

    =IFERROR(INDIRECT(TEXT(AGGREGATE(15,6,10^5*ROW($15:$23)+COLUMN($B:$K)/((COUNTIFS($B$15:$K$23,$B$15:$K$23,$B$15:$K$23,">"&"A")=MAX(INDEX(COUNTIFS($B$15:$K$23,$B$15:$K$23,$B$15:$K$23,">"&"A"),)))*(COUNTIF($M$15:M15,$B$15:$K$23)=0)),COLUMNS($A:A)),"R0C00000"),0),"")


    Saluti
    Attached Files Attached Files

+ 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] Blank cells in an "IF" & "AND" formula.
    By Terry-J in forum Excel General
    Replies: 3
    Last Post: 08-12-2018, 03:57 PM
  2. Replies: 0
    Last Post: 02-14-2018, 06:14 PM
  3. How do I create a "counting" formula that tallies up specific cells filled in?
    By hoodleehoo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-20-2017, 08:37 PM
  4. [SOLVED] Copy cells from range "C3" to "F3" with loop and blank field
    By masterm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2015, 01:03 PM
  5. [SOLVED] Keeping particular cell blank if the related cells show "0" or "blank"
    By Anuru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-24-2014, 05:30 AM
  6. [SOLVED] Replace all BLANK cells in column with header title "Balance" to "0"
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2014, 09:25 AM
  7. Replies: 3
    Last Post: 09-29-2009, 06:42 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