Solved

Getting a Totals Query to show 0 values

Posted on 2006-11-03
1
276 Views
Last Modified: 2012-06-27
I have a report that has a graph.  The data source for the graph is a query.  I want to have the graph legend show all of the catagories, even if the count is zero.  What is the best way to do this?  The method I've tried, and it does not work, is to create two queries (Named Query2 and AllZeros) that feed a 3rd query (Query3), and then use the 3rd query as the datasource for the graph.

Here is the code for each query:

***All Zeros (The job of this query is to set a zero value for each catagory.  It successfully reports 0 for all catagories):
SELECT Format([Date],"ww/yyyy") AS Week, [List: Factories].Supplier, [List: Errors].[Error Catagory], 0 AS [Error Count]
FROM [List: Errors], [List: Factories], [Rework Errors]
GROUP BY Format([Date],"ww/yyyy"), [List: Factories].Supplier, [List: Errors].[Error Catagory], 0;

***Query2 (The job of this query is to report the actual count of rework errors, which it does correctly):
PARAMETERS [Forms]![Menu]![StartDate] DateTime, [Forms]![Menu]![EndDate] DateTime;
SELECT [Rework Errors].Factory, Format([Date],"ww/yyyy") AS [Week/Year], [Rework Errors].[Error Catagory], Count([Rework Errors].[Error Catagory]) AS [CountOfError Catagory]
FROM [Rework Errors]
WHERE ((([Rework Errors].Date) Between [Forms]![Menu]![StartDate] And [Forms]![Menu]![EndDate]))
GROUP BY [Rework Errors].Factory, Format([Date],"ww/yyyy"), [Rework Errors].[Error Catagory]
ORDER BY Format([Date],"ww/yyyy"), Count([Rework Errors].[Error Catagory]) DESC;

***Query3 (now, for some reason i thought if you added together the 0 value from the "allzeros" query and the error count from "query2", you would get a display of all catagories, even if they are zero value, however this is not the case):
SELECT Query2.Factory, Query2.[Week/Year], Query2.[Error Catagory], IIf(([All Zeros]![Error Count]+Query2![CountOfError Catagory])=0,0,([All Zeros]![Error Count]+Query2![CountOfError Catagory])) AS Expr1
FROM [All Zeros] INNER JOIN Query2 ON ([All Zeros].Week = Query2.[Week/Year]) AND ([All Zeros].[Error Catagory] = Query2.[Error Catagory]) AND ([All Zeros].Supplier = Query2.Factory)
GROUP BY Query2.Factory, Query2.[Week/Year], Query2.[Error Catagory], IIf(([All Zeros]![Error Count]+Query2![CountOfError Catagory])=0,0,([All Zeros]![Error Count]+Query2![CountOfError Catagory]));


What is the best way to accomplish this?  I want all catagories to be displayed in teh query, even if they are 0 value.
0
Comment
Question by:loscomp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 54

Accepted Solution

by:
nico5038 earned 250 total points
ID: 17866531
The basic approach will be to have a mandatory list of categories and JOIN this list/table with the data using an OUTER JOIN being a "LEFT" or "RIGHT" join in Access.
Just use the graphical query editor and doubleclick the JOIN line to select option 2 or 3 to make the categories "leading"

Getting the idea ?

Nic;o)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question