Results 1 to 4 of 4
  1. #1
    Fish218 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    68

    Counting text values

    I want to run a query that counts one text value "n" in a table and also counts all other possible text values other than "n" but without grouping them into each individual text value.



    For example:

    In a table I have 10 "n" values, 10 "a" values, 5 "b" values, and 1 "c" value. i want the query to return a single line showing the count of "n" = 10 and the count of "a" and "b" and "c" = 16. Any suggestions?


    n not n
    10 16

  2. #2
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    Fish218 - If the alpha values are in one specific field, you could create a query based on the table that contains the alpha field. Then add two calculated fields/columns.
    Col1 - N: IIf([fieldnamewithalphavalues]= "n",1,0)
    Col2- O: IIF([fieldnamewithalphavalues]<> "n",1,0)

    Next, create a new query based upon the first, click the summary button, then sum the fields N and O. Last, run the total/aggregrate query.

    This should produce the desired results. However, if the alpha values are not in a specific field or the field contains other elements, this method will not work.

    All the best,

    Jim

  3. #3
    uncletreetrunk is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2012
    Posts
    72
    Hey fish,

    I think you can use the DCount function so in your query in the field box:

    DCount("FieldName","tblName","Type = 'n' ")

    Source:http://www.techonthenet.com/access/f...ain/dcount.php

  4. #4
    Fish218 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    68
    The two seperate column IIF statement worked well! Thanks.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-21-2012, 02:06 PM
  2. counting values
    By webisti in forum Access
    Replies: 1
    Last Post: 11-18-2011, 07:28 AM
  3. help counting distinct values
    By joo-joo-man in forum Queries
    Replies: 2
    Last Post: 10-17-2010, 05:18 AM
  4. Counting text occurences
    By katie_88 in forum Queries
    Replies: 3
    Last Post: 07-19-2010, 10:46 AM
  5. Replies: 1
    Last Post: 11-11-2006, 08:00 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