Solved

Getting a Totals Query to show 0 values

Posted on 2006-11-03
1
275 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

726 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