+ Reply to Thread
Results 1 to 7 of 7

COUNTIF vs IF function history lesson

  1. #1
    Registered User
    Join Date
    02-21-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    4

    COUNTIF vs IF function history lesson

    I know the quotation marks create a text string, and I know the ampersand concatenates two text strings or concatenates a cell reference to a text string, but I’m wondering why <= or >= has to be a text string to work in COUNTIF?

    If I do an formula like =IF(B3>0,”YES”,”NO”), this works fine, without having to add special characters (i.e. =IF(B3&”>0”,”YES”,”NO).

    But for COUNTIF, a formula like =COUNTIF(B1:B5,>0) won’t work unless you make it =COUNTIF(B1:B5,”>0”).

    I understand what to do to get the formulas to work, I guess I’m just confused as to WHY the criteria rules for COUNTIF are different from regular IF.


    One of my peers is offering a free lunch to anyone who knows the reasoning and they said the hint is "I am old".

    Any insight?!

    Thanks!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: COUNTIF vs IF function history lesson

    B3>0 is a logical expression that is evaluated and passed to the function as a Boolean

    In =COUNTIF(B1:B5, ”>0”), the second argument is passed to the function as string

    In =COUNTIF(B1:B5, >0), the second argument is not a valid expression
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    02-21-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: COUNTIF vs IF function history lesson

    but WHY, was there and older version that was different?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: COUNTIF vs IF function history lesson

    Why what?

    No difference in versions at least back to Excel 97.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: COUNTIF vs IF function history lesson

    In this

    =SUMPRODUCT(--(B1:B5>0))

    ... the B1:B5>0 is a valid expression

    Again, >0 standing by itself is not a valid expression.

  6. #6
    Forum Contributor
    Join Date
    12-09-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    171

    Re: COUNTIF vs IF function history lesson

    COUNTIF(range, criteria)


    range Required. One or more cells to count, including numbers or names, arrays, or references that contain numbers. Blank and text values are ignored.

    criteria Required. A number, expression, cell reference, or text string that defines which cells will be counted. For example, criteria can be expressed as 32, ">32"

    In the criteria, if you are providing any expression, that should be provided as a string, this is specially passing due to the consider as a single argument.
    Like my answer, then click * below

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: COUNTIF vs IF function history lesson

    Maybe you meant why is this not valid:

    =COUNTIF(B1:B5>0)

    The answer is that all of the *IF functions (COUNTIF, COUNTIF, AVERAGEIF, ...) require a range, not an array, as the first argument.

+ 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. Need Help Designing a Lesson Planning System
    By snwbrdr18 in forum Excel General
    Replies: 1
    Last Post: 10-15-2013, 10:46 AM
  2. HELP! need a lesson on referencing and error checking two cells
    By wiskydiver25 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2012, 01:28 AM
  3. Lesson reservation calendar
    By Frungy in forum Excel General
    Replies: 8
    Last Post: 08-06-2011, 04:35 AM
  4. Populate History Sheet from Custom function Variables (vlookup)
    By exc4libur in forum Excel Programming / VBA / Macros
    Replies: 40
    Last Post: 04-14-2011, 10:25 AM
  5. Excel Should Have a History Function.
    By Ray M. in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-23-2005, 04:05 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