Results 1 to 5 of 5
  1. #1
    CJFugate is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Jul 2017
    Posts
    3

    Count if "YES"

    Hi All!

    I have a a query the spits out a column populated by either a "YES" or a "NO". How can I total the number of times "YES" appears?



    Thanks!

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,387
    if the yes/no is a Boolean field, you can use a group by query and sum the column*-1 or use the abs function. (Booleans store yes as -1 and no as 0)

    if it is a text field then you need to use an iif function and sum that iif(yesnofield="Yes",1,0)

  3. #3
    CJFugate is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Jul 2017
    Posts
    3
    The YES/NO is a short text field. Where in my query do I put the iif function?

    Thanks!

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,387
    your query will be something like


    SELECT Sum(iif(yesnofield="Yes",1,0)) as ttlYes
    FROM myTable

  5. #5
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    If you only want it in a text box how about dcount("fieldname",
    "queryname,fieldname= "yes")

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 01-23-2017, 07:06 PM
  2. Replies: 4
    Last Post: 12-20-2015, 12:16 PM
  3. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  4. Replies: 1
    Last Post: 03-30-2011, 06:16 PM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums