Results 1 to 5 of 5
  1. #1
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501

    Use count or countif and exclude certain customer id

    I want to count customerID in a table but I want to exclude 3 id's. Is there a way to do this with count or countif on an access form?

    I have tried countif([CustomerId[, Not in (3,8,9))
    =Countif([Car Initials],<>3 or <>8 or <> 9)
    =Countif([Car Initials],<>3,8,9)

    None of those are allowed

    Also, when i try to do it in a regular query Not in (3,8,9) works but if I change it to a totals query and use the count function it does not work.

  2. #2
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    Silly me, i just had to do the count on another field and add a where condition for the main field

    Ex; =DCount("RailcarID","AllRailcarData","CustomerID not in (3,8,9)")

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    T1 is your main data table,
    T2 holds the keys you dont want
    in the query join the 2 tables on key
    set to OUTER join, dbl click the join line, set for :ALL recs in T1.
    bring down the key field from both tables,
    under T2 key, set criteria IS NULL
    run query,


    you will only get the items NOT in T2 table.
    or your way too.

  4. #4
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    Interesting, I like that idea of creating a separate table with the values I dont want and then I can just add new values at any time and the report will be updated. I am going to give it a try, thanks

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

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

Similar Threads

  1. SQL Count and countif in single Query
    By naseerrahaman in forum Queries
    Replies: 4
    Last Post: 01-02-2021, 08:22 AM
  2. Replies: 6
    Last Post: 12-11-2013, 09:27 PM
  3. "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