Re: Counting yes values only in query

From: John Spencer (MVP) (spencer4_at_comcast.net)
Date: 06/21/04


Date: Mon, 21 Jun 2004 19:16:25 -0400

First of all WHICH FIELD is yes or no? Is that field a text field, a yes/no
field, or a date field, or a number field?

To trouble shoot this, break the query down to just one YES/No field and see if
you get what you are expecting. Once you have done that then you can expand
your query and add in more fields.

Open a query
Select Totals from the View menu
Enter the following in two field cells.

Field: DateByMonth: FORMAT([Date of Decision/Interview],"mmmm yyyy")
Total: Group By

Field: CountOfInitialInterview: Abs(Sum([Initial Interview]))
Total: Expression

Does that return what you want? If not, what does it return? Does it return an
error or some other message? What is the message? We cannot see what you are
getting, you can. So please help us help you, but telling us what you do see.

Also, don't forget to tell us what type of field [Initial Interview] is? If it
is not a yes/no field, try

  Abs(Sum([initial interview]="Yes"))

Katt wrote:
>
> Sorry to be a pain about this but I get an error message
> from this statement. I am prompted to enter a query
> restriction. Yes, Y, and True elicit no responses.
> Is there a way to do this from design view instead of in
> the SQL writing mode? Sorry to be picky but I need a
> query to disregard any NO statements.
> -Katt
> >-----Original Message-----
> >Pardon me for jumping in.
> >
> >REVISED QUERY: This assumes that when you are counting
> you want to count "yes"
> >values in the field AND that the field is a Yes/No type
> (boolean) field. I've
> >also aliased the table name as I to make it easier to
> type the revision
> >
> >
> >SELECT Format([I].[Date of decision/interview],'mmmm
> yyyy')
> >AS [Date of decision/interview By Month],
> >[I].[Form type],
> >Abs(Sum([I].[Initial Interview])) AS [CountOfInitial
> Interview],
> >Abs(Sum([I].[Initial Interview No Show])) AS
> [CountOfInitial Interview No Show],
> >Abs(Sum([I].[No Show Rescheduled]) )AS [CountOfNo Show
> Rescheduled],
> >Abs(Sum([I].Approve)) AS CountOfApprove,
> >Abs(Sum([I].[Deny - Other]) )AS [CountOfDeny - Other],
> >Abs(Sum([I].[Deny - Fraud])) AS [CountOfDeny - Fraud],
> >Abs(Sum([I].[Continued?]) )AS [CountOfContinued?],
> >Abs(Sum([Initial entry].[Continued Grant]) )AS
> [CountOfContinued Grant],
> >Abs(Sum([I].[Continued Deny - Other])) AS
> [CountOfContinued Deny - Other],
> >Abs(Sum([I].[Continued Deny - Fraud])) AS
> [CountOfContinued Deny - Fraud]
> >FROM [Initial entry] As I
> >GROUP BY Format([I].[Date of decision/interview],'mmmm
> yyyy'),
> > [I].[Form type],
> > Year([I].[Date of decision/interview]) *12+
> > DatePart('m',[I].[Date of decision/interview])-1
> >ORDER BY Format([I].[Date of decision/interview],'mmmm
> yyyy'),
> > [I].[Form type];
> >.
> >



Relevant Pages

  • Re: Report is making too many numbers
    ... from the $'s being listed more than once in the query. ... And you want to display the sum of in the Vendor header or footer ... My report is based on a query. ... those records--you could create a Totals query by depressing the ...
    (microsoft.public.access.reports)
  • Re: Running balance from two tables
    ... the TOTALS button and show a totals line in the query, ... my total additions and my total costs and see how much money is in my ... What I'd love to do with it is have something pop up when the balance is ...
    (microsoft.public.access.queries)
  • RE: Updating the 1st Instance of a Record
    ... As the others have pointed out you shouldn't store the totals but compute ... In a query you can return the total per order provided you don't ... This second query will return the total amount per order in every row of its ... and an unbound control in the group footer with a ControlSource ...
    (microsoft.public.access.gettingstarted)
  • RE: Crosstab Worries
    ... I copied your sql into my Northwind and I created a form off that query and I ... concerned, the recordsource is three letters, Jan, Feb, but the text box is ... You can sum a field from the record source but not ... with their totals in each of the twelve columns. ...
    (microsoft.public.access.queries)
  • RE: Cannot get code to work for API Save Dialog Box
    ... While I still need help on that other issue, I fixed the totals problem I had. ... The first spreadsheet placed where I told it to be contains the incorrect ... Set xlSheet = Nothing ... query, you will have to add the field to your query. ...
    (microsoft.public.access.forms)