473,324 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Suppress Zero values in a Cross Tab report

Hello, hope somebody here can help me... I have a query that lists
defects recorded in a user defined date range. That query is then used
as the source for a Cross Tab query that cross-tabs count of defect
type by calendar month. Defect types are stored in one table, defect
transactions in another along with date etc. When I cross-tab the
results, defect types that have no defects recorded against them
appear as a blank (null) value. That is, the zero value is suppressed.
Unfortunately, in the management reports that are produced, they (QA
Managers) want to see a Zero value, not a null value. (they postulate
that a null could be interpreted as "we forgot to count those
values...", NOT "we had no defects of that type..)

Is there a simple way to "un"-suppress zero values. I had thought of
doing an Immediate If, (that is, Iif count=Null, show "0", otherwise
show Count) but cannot get that to work...
I also thought of giving each transaction a notional value of "1",
then summing the results in a cross tab, but since a defect count is
null because we haven't recorded any transactions of that type, you
can't sum something that isn't there! A third option was to use the
immediate if in the "OnFormat" event of the report itself - still
can't make it work...

Any help would be hugely appreciated. Thanks in advance.

THE SQL statement for the current query is as follows:

TRANSFORM Count(QryComplaintSummary.RecordID) AS [The Value]
SELECT QryComplaintSummary.DefectTypeDesc,
Count(QryComplaintSummary.RecordID) AS [Total Of RecordID]
FROM QryComplaintSummary
GROUP BY QryComplaintSummary.DefectTypeDesc
PIVOT Format([Complaint Date],"mmm") In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");
Nov 13 '05 #1
4 5537
Hello
Surprise, surprise: you have to do it other way! I usually have to
supress printing zeros...
If you can define transactions column in the table as number,
cross-tab query will calculate zeros as default, I think.
Galina
da********@optusnet.com.au (David Peach) wrote in message news:<ee**************************@posting.google. com>...
Hello, hope somebody here can help me... I have a query that lists
defects recorded in a user defined date range. That query is then used
as the source for a Cross Tab query that cross-tabs count of defect
type by calendar month. Defect types are stored in one table, defect
transactions in another along with date etc. When I cross-tab the
results, defect types that have no defects recorded against them
appear as a blank (null) value. That is, the zero value is suppressed.
Unfortunately, in the management reports that are produced, they (QA
Managers) want to see a Zero value, not a null value. (they postulate
that a null could be interpreted as "we forgot to count those
values...", NOT "we had no defects of that type..)

Is there a simple way to "un"-suppress zero values. I had thought of
doing an Immediate If, (that is, Iif count=Null, show "0", otherwise
show Count) but cannot get that to work...
I also thought of giving each transaction a notional value of "1",
then summing the results in a cross tab, but since a defect count is
null because we haven't recorded any transactions of that type, you
can't sum something that isn't there! A third option was to use the
immediate if in the "OnFormat" event of the report itself - still
can't make it work...

Any help would be hugely appreciated. Thanks in advance.

THE SQL statement for the current query is as follows:

TRANSFORM Count(QryComplaintSummary.RecordID) AS [The Value]
SELECT QryComplaintSummary.DefectTypeDesc,
Count(QryComplaintSummary.RecordID) AS [Total Of RecordID]
FROM QryComplaintSummary
GROUP BY QryComplaintSummary.DefectTypeDesc
PIVOT Format([Complaint Date],"mmm") In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");

Nov 13 '05 #2
On 8 Aug 2004 23:46:47 -0700, da********@optusnet.com.au (David Peach)
wrote:
Hello, hope somebody here can help me... I have a query that lists
defects recorded in a user defined date range. That query is then used
as the source for a Cross Tab query that cross-tabs count of defect
type by calendar month. Defect types are stored in one table, defect
transactions in another along with date etc. When I cross-tab the
results, defect types that have no defects recorded against them
appear as a blank (null) value. That is, the zero value is suppressed.
Unfortunately, in the management reports that are produced, they (QA
Managers) want to see a Zero value, not a null value.


Hi David

There may be some simple way, but I think you need to run the crosstab
on a query which already contains all the required table entries. For
example you can form a cross product (all pairs month/defect) by a
query "AllRequiredPairs" such as

SELECT DefectTypes.DefectType, MonthsTable.mnth
FROM DefectTypes, MonthsTable;

(MonthsTable is just a list "Jan", "Feb", "Mar "etc)

You can then form a query "Group1" which is the union of the required
pairs with the actual defects which have occurred.

SELECT DefectOccurrences.DefectType, Format([Complaint Date],"mmm")
AS mnth, "actual defect"
FROM DefectOccurrences
UNION Select DefectType, mnth, "dummy entry" from
AllRequiredEntries;

(I have added the third unnamed column to the union to make sure that
all records are unique otherwise it won't work. These two queries
could be combined)

Finally the crosstab can be something like

TRANSFORM Count([DefectType])-1
SELECT group1.DefectType FROM group1
GROUP BY group1.DefectType
PIVOT group1.mnth In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");

where the minus one removes the "dummy" required items.

David

Nov 13 '05 #3
David, Thanks for your help, but there's an easier way - provided to
me by a genius in another Access forum...(its probably not polite to
say here which forum...!) Following is his code not mine....

=========================
Replace

Count(QryComplaintSummary.RecordID)

with

Nz(Count(QryComplaintSummary.RecordID),0)

The Nz function returns its first argument but replacess null values
by the second argument. Usually, the result of Nz is text. If you need
numeric values for further calculations, use

CLng(Nz(Count(QryComplaintSummary.RecordID),0))

=============================
I'd never used the Nz function before - very handy. This worked a
treat and is very simple & elegant.

Thanks for the follow -up though - much appreciated.

dp


d.***************@blueyonder.co.uk (David Schofield) wrote in message news:<4117b0ef.745334354@localhost>...
On 8 Aug 2004 23:46:47 -0700, da********@optusnet.com.au (David Peach)
wrote:
Hello, hope somebody here can help me... I have a query that lists
defects recorded in a user defined date range. That query is then used
as the source for a Cross Tab query that cross-tabs count of defect
type by calendar month. Defect types are stored in one table, defect
transactions in another along with date etc. When I cross-tab the
results, defect types that have no defects recorded against them
appear as a blank (null) value. That is, the zero value is suppressed.
Unfortunately, in the management reports that are produced, they (QA
Managers) want to see a Zero value, not a null value.


Hi David

There may be some simple way, but I think you need to run the crosstab
on a query which already contains all the required table entries. For
example you can form a cross product (all pairs month/defect) by a
query "AllRequiredPairs" such as

SELECT DefectTypes.DefectType, MonthsTable.mnth
FROM DefectTypes, MonthsTable;

(MonthsTable is just a list "Jan", "Feb", "Mar "etc)

You can then form a query "Group1" which is the union of the required
pairs with the actual defects which have occurred.

SELECT DefectOccurrences.DefectType, Format([Complaint Date],"mmm")
AS mnth, "actual defect"
FROM DefectOccurrences
UNION Select DefectType, mnth, "dummy entry" from
AllRequiredEntries;

(I have added the third unnamed column to the union to make sure that
all records are unique otherwise it won't work. These two queries
could be combined)

Finally the crosstab can be something like

TRANSFORM Count([DefectType])-1
SELECT group1.DefectType FROM group1
GROUP BY group1.DefectType
PIVOT group1.mnth In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");

where the minus one removes the "dummy" required items.

David

Nov 13 '05 #4
>Replace

Count(QryComplaintSummary.RecordID)

with

Nz(Count(QryComplaintSummary.RecordID),0)


How embarrassing. This is the first thing I tried but through years of
sloppy programming I used Nz without the second argument. I see in the
help file that the second argument is "Optional (unless used in a
query)"
So I have learned something as well!!

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Doug Ly | last post by:
Hi, When I run this query using WinSQL to connect to a DB2 database, it gave me the warning: Error: SQLSTATE 01003: Null values were eliminated from the argument of a column function. ...
2
by: Tony | last post by:
Hi all, I have a table with numerical information in it (scientific notation) and a simple report that displays this information relevant to a query on the data. My question - Some of the...
5
by: Randy Harris | last post by:
How can I report an average of non zero values? If the values are: 5, 0, 6, 0, 4 I would like the result 5 (15 / 3), not 3 (15 / 5) Thanks for any help...
1
by: Bill Nguyen | last post by:
Report source is an SQLSERVER 2K store procedure. VB.NET application. Report created by CR 8.5. At runtime, I still had to click "CANCEL" to bypass the parameter prompts before the report display...
2
by: pmarisole | last post by:
I am trying to write a report that displays a hierarchy such as: Director, Manager, Employee I want to suppress the repeating Director, Manager for the employees. This is my code: sSQL =...
2
by: keithsimpson3973 | last post by:
Hi, working in Access 2003. In my report, I have a field that contains a qty. If the qty is equal to zero , then I would like access not to display that record on the report. I thought you could do...
12
by: jenniferhelen | last post by:
I would like to suppress a row of data if each of my 5 currency columns contains a zero. An example of 1 record is below: Col 1, col 2, col 3, col 4, col 5, col 6, col7, col 8 Smith, ...
0
by: dragon52 | last post by:
Hi there, I have records in the form of scorecards. Each scorecard has fields "type" and "score". eg typeA 2.3 typeB 3.3 typeA 2.0 typeC 1.9 typeB 1.1
3
mseo
by: mseo | last post by:
hi, I have a report connected to a form where I can print the invoices between the two dates in the form but I have the problem: when the checkbox = true refers to Canceled invoice but the values...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.