+ Reply to Thread
Results 1 to 10 of 10

Use COUNTIF to count another formulas output

  1. #1
    Registered User
    Join Date
    02-17-2015
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    26

    Question Use COUNTIF to count another formulas output

    Hello!

    I'm hoping someone can help me solve a likely simple problem that is a bit outside my skill level.

    I am trying to use COUNTIF to count the number of cells on another sheet that have a value of "TRUE".

    The formula is =COUNTIF('Sheet1'!AI:AI,"TRUE"). However, it returns a 0.

    If I manually add the word TRUE to that column, it will return the value.

    I assume COUNTIF needs some other flag to read the formula's output from column AI, and not read the text of the formula itself.

    Any help?

    Thank you.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Use COUNTIF to count another formulas output

    Try removing the quotes from "TRUE"

  3. #3
    Registered User
    Join Date
    02-17-2015
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    26

    Re: Use COUNTIF to count another formulas output

    Thanks for the reply. Still returns a 0, not the actual value.

    Essentially I need to find a way to count or reference a formula's output, not the formula itself.

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Use COUNTIF to count another formulas output

    That's what formulas do, they look at the result (output) of other formulas.

    What is the actual formula you have in Sheet1 column AI ?

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Use COUNTIF to count another formulas output

    The words True and False are special keywords in Excel. A Boolean value result from a calculation with a binary True or False value.
    The countif function is looking for that value (despite having " marks around it).
    If your formula in column AI is returning an actual TEXT String with quotes like
    =IF(A1=5,"TRUE")
    Then countif won't count it.

    You would need to make that formula return a true Boolean (without the quotes)
    =IF(A1=5,TRUE)
    Or just simply
    =A1=5

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,840

    Re: Use COUNTIF to count another formulas output

    Agree with Jonmo1 -- more information is needed. I can kind of replicate the problem. I:

    1) Entered =RANDBETWEEN(0,1)=1 into a dozen cells to get a set of random boolean TRUE/FALSE values (are your values boolean values or text strings?)
    2) using this range, =COUNTIF(A3:A25,TRUE) correctly counted the number of boolean TRUE values.
    3) Converted to text in another column =IF(A3,"TRUE","FALSE")
    4) On tjhis range, the COUNTIF() function failed. =COUNTIF(B3:B25,"TRUE") returned 0.

    So my best guess at this point is that your boolean values are actually text strings, and COUNTIF() does not want to recognize that particular text string (I would guess that COUNTIF() internally converts "TRUE"/"FALSE" text strings to the actual boolean values. If this is indeed what is happening in your sheet, I recommend either choosing a different text string ("Yes"/"No") maybe, or use the actual boolean values TRUE/FALSE (and not text strings).
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  7. #7
    Registered User
    Join Date
    02-17-2015
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    26

    Re: Use COUNTIF to count another formulas output

    What I have is this:

    =IF(AND(AF2="Yes",OR(AG2="Yes",AH2="Yes")),"TRUE","FALSE".
    So The formula in AI looks in AF2, AG2, AH2 for the word Yes in any of the three cells and will display TRUE if they have a Yes or False if they are all No.

    I want to show how many times on another dashboard style worksheet that the number of TRUE from AI occurs.

    Does that make sense?

  8. #8
    Registered User
    Join Date
    02-17-2015
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    26

    Re: Use COUNTIF to count another formulas output

    So what you said about the use of True and False struck a chord with me.

    I changed the formula in AI to output Yes and No, and used =COUNTIF('Sheet1'!AI:AI,"Yes") and it returned a correct value, in this case 37.

    Thanks for your help everyone!

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: Use COUNTIF to count another formulas output

    As has already been mentioned, remove the quotes from around the TRUE and FALSE
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Use COUNTIF to count another formulas output

    I would do it like this
    =AND(AF2="Yes",OR(AG2="Yes",AH2="Yes"))
    This will return the more desirable and usable aforementioned Boolean True or False results

    Then your original formula (with quotes removed) will work.

+ 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. IF formula with formulas within output
    By Rick-O-Shay in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-24-2018, 04:11 PM
  2. [SOLVED] COUNTIF with a max value output.
    By bodine1187 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-13-2017, 12:51 PM
  3. CountIf/Count Function displaying incorrect output
    By communistflamingo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-14-2015, 03:44 PM
  4. [SOLVED] Countif with Sumif is producing a single error in output
    By sipa in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 12-30-2014, 07:34 AM
  5. [SOLVED] Combine two formulas to count (countif and productsum)
    By keis386 in forum Excel General
    Replies: 2
    Last Post: 07-24-2012, 03:36 AM
  6. If Countif Output Count Rank SUMPRODUCT
    By SunOffice in forum Excel General
    Replies: 12
    Last Post: 09-03-2010, 05:00 AM
  7. Sorting Output with Formulas in It
    By mycon73 in forum Excel General
    Replies: 4
    Last Post: 01-05-2009, 12:27 AM

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