473,289 Members | 1,839 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,289 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 5534
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
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: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.