Results 1 to 2 of 2
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862

    Can't get the count if fiedl is Null

    I have three fields that Votes="Defer" and Final_Vote is Null. Votes field is correct.



    Code:
    TRANSFORM Nz(Count([CR_ID])-1,0) AS CR_IDs
    SELECT Chng_ReqQry.Level, Nz(Count([CR_ID])-5,0) AS [HB Totals]
    FROM Chng_ReqQry
    WHERE (((Chng_ReqQry.Sub_No)=0) AND ((Chng_ReqQry.Date_Closed) Between Now() And Date()-7))
    GROUP BY Chng_ReqQry.Level
    PIVOT IIf(Not IsNull([Final_Vote]),[Final_Vote],(IIf(Not IsNull([GO_Vote]),[GO_Vote],(IIf(Not IsNull([O6_Vote]),[O6_Vote],[AO_Vote])))));
    What am I missing that it will not count the 3 "Defer"? The count Header does not display <>, so I am assuming it is not counting where Final_Vote is null. Could it be that it is not counting that "Level"?

    IIf(Not IsNull([Final_Vote]),[Final_Vote],(IIf(Not IsNull([GO_Vote]),[GO_Vote],(IIf(Not IsNull([O6_Vote]),[O6_Vote],[AO_Vote]))))) Gets me the Withdrawn count, recognizes Deferred, but not Defer

    IIf(Not IsNull([GO_Vote]),[GO_Vote],(IIf(Not IsNull([O6_Vote]),[O6_Vote],[AO_Vote]))) Recognizes Defer and gets me the Defer count, but not the Withdraw count.

  2. #2
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by Thompyt View Post
    I have three fields that Votes="Defer" and Final_Vote is Null. Votes field is correct.

    Code:
    TRANSFORM Nz(Count([CR_ID])-1,0) AS CR_IDs
    SELECT Chng_ReqQry.Level, Nz(Count([CR_ID])-5,0) AS [HB Totals]
    FROM Chng_ReqQry
    WHERE (((Chng_ReqQry.Sub_No)=0) AND ((Chng_ReqQry.Date_Closed) Between Now() And Date()-7))
    GROUP BY Chng_ReqQry.Level
    PIVOT IIf(Not IsNull([Final_Vote]),[Final_Vote],(IIf(Not IsNull([GO_Vote]),[GO_Vote],(IIf(Not IsNull([O6_Vote]),[O6_Vote],[AO_Vote])))));
    What am I missing that it will not count the 3 "Defer"? The count Header does not display <>, so I am assuming it is not counting where Final_Vote is null. Could it be that it is not counting that "Level"?
    replace the null values with a value of 0

    I think you can do this using the nz() function

    so in the query have nz([Field],0)

    that way if it is null it will access to make the field with a value of 0 and then calculate.

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

Similar Threads

  1. Count query return zero instead of null/blank
    By dhicks19 in forum Queries
    Replies: 1
    Last Post: 04-19-2012, 07:52 AM
  2. Count if Null Expression
    By Huddle in forum Reports
    Replies: 3
    Last Post: 03-07-2012, 04:43 PM
  3. Count() and Null Values
    By jpvonhemel in forum Queries
    Replies: 4
    Last Post: 10-21-2011, 03:37 AM
  4. Displaying Count if Null value exists
    By adams.bria in forum Queries
    Replies: 3
    Last Post: 08-31-2011, 11:56 AM
  5. use 0 for null value in count query
    By hyperionfall in forum Queries
    Replies: 1
    Last Post: 11-07-2010, 05:12 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