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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
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.
DeptCount
Dept 145
Dept 225
Dept 336
4
<colgroup><col width="64" style="width: 48pt;" span="2"> <tbody> </tbody>
 
Upvote 0
Try adding the DEPT field to your criteria (WHERE) section, excluding records where that field is blank.
 
Upvote 0
You are welcome!
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

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