Do not display 0 if there is no count

Tcurtis

Board Regular
Joined
Aug 15, 2009
Messages
149
I am using a query to count how many Departments there are according to a set of criteria. The count always shows a blank field if the field has nothing in it, How do I make this not show a blank field. I am including my sql below.

SELECT TOP 10 tbl_Cause_Code_Dashboard.Description, Count(tbl_Cause_Code_Dashboard.Description) AS CountOfDescription
FROM tbl_Cause_Code_Dashboard
WHERE (((tbl_Cause_Code_Dashboard.Plant)=[Forms]![frm_Cause_Code_Dashboard]![Plants]) AND ((tbl_Cause_Code_Dashboard.OEM_Model)=[Forms]![frm_Cause_Code_Dashboard]![Model]) AND ((tbl_Cause_Code_Dashboard.Cause_Code_Long)=[Forms]![frm_Cause_Code_Dashboard]![Cause_Code]))
GROUP BY tbl_Cause_Code_Dashboard.Description
ORDER BY Count(tbl_Cause_Code_Dashboard.Description) DESC;
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Not quite sure I follow.

Can you post a small sample of your data, what result you are seeing, and what your expected result should look like?
 
Upvote 0
The highlighted cells are what I am wondering about. The department is blank with no counts but it keeps showing up in my query output.
[TABLE="width: 96"]
<colgroup><col width="64" style="width: 48pt;" span="2"> <tbody>[TR]
[TD="class: xl65, width: 64, bgcolor: transparent"]Dept[/TD]
[TD="class: xl65, width: 64, bgcolor: transparent"]Count[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]Dept 1[/TD]
[TD="class: xl65, bgcolor: transparent, align: right"]45[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]Dept 2[/TD]
[TD="class: xl65, bgcolor: transparent, align: right"]25[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]Dept 3[/TD]
[TD="class: xl65, bgcolor: transparent, align: right"]36[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"] [/TD]
[TD="class: xl65, bgcolor: transparent, align: right"]4[/TD]
[/TR]
[TR]
[TD="class: xl66, bgcolor: yellow"] [/TD]
[TD="class: xl66, bgcolor: yellow"] [/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Try adding the DEPT field to your criteria (WHERE) section, excluding records where that field is blank.
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top