?
Solved

Getting a Totals Query to show 0 values

Posted on 2006-11-03
1
Medium Priority
?
278 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 750 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

752 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