Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display a zero when no value 2

Status
Not open for further replies.

ruthcali

Programmer
Joined
Apr 27, 2000
Messages
470
Location
US
I am using Access97.

In my crosstab query, can i have Access display a zero when there is no value for that row? At the moment, it displays an empty cell.

Thanks,
ruth
ruth.jonkman@wcom.com
 
Hi,
thanks for writing. but where in the crosstab query would i use the NZ function?

My crosstab query looks at the fields loc1 and loc2 (the 2 row headings) and looks at the field circuit class as the column and does a count of how many circuits can be found.

TRANSFORM Count(Circuit) AS [The Value]
SELECT Loc1, Loc2, Count(Circuit) AS [Total Of Circuit]
FROM tblCircuit
GROUP BY Loc1, Loc2
PIVOT CircuitClass In ("DS3","OC03","OC12","OC48");

Thanks
 
Ruth,

What field(s) do you want to do this to?? Loc1 & Loc2??
 
the Total field.
for example, now my results data looks like:

Loc1 Loc2 Total_of_Circuits DS3 OC3 OC12 OC48
AB XG 3 3
BG IF 7 1 5 1


And i want it to look like:
Loc1 Loc2 Total_of_Circuits DS3 OC3 OC12 OC48
AB XG 3 3 0 0 0
BG IF 7 1 5 1 0
 
the Pivot Count field.
for example, now my results data looks like:

Loc1 Loc2 Total_of_Circuits DS3 OC3 OC12 OC48
AB XG 3 3
BG IF 7 1 5 1


And i want it to look like:
Loc1 Loc2 Total_of_Circuits DS3 OC3 OC12 OC48
AB XG 3 3 0 0 0
BG IF 7 1 5 1 0
 
sorry, i hit Submit too soon on that post. and i think my column fields got mis-aligned.

I would like the zeros to appear on the Pivot Count field.
 
I don't know if this will work......Change the TRANSFORM statement to:
Code:
TRANSFORM IIf(IsNull(Count(Circuit)),0,Count(Circuit)) AS [The Value]

 
Cosmo--it works!! you're a genius. thank you so much. wow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top