Count If in Access 2016?

britsgal

Board Regular
Joined
Apr 8, 2014
Messages
75
Office Version
  1. 365
Platform
  1. Windows
Good Afternoon,

I know I can perform a "countif" in Excel but just wondering how I can do that in Access? I really don't want to use code just simple formula would work if that's possible. Here's what I want to do, I have a table containing location, item and on hand. I would like to count the # of zeroes or qty's less than zero by location. The table looks something like this. So in this case location "A" would have 3, Location "B" would have 1, and location "C" would have 3. Any help is appreciated.
LOCATIONITEMOn Hand
A10
A2-3
A34
A4-1
A59
A66
B60
B46
C30
C20
C10
C49

<tbody>
</tbody><colgroup><col><col span="2"></colgroup>
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I would do this with two queries.

Query1
Code:
SELECT Sheet1.LOCATION, IIf([On Hand]<1,1,0) AS Cnt
FROM Sheet1;

Query2
Code:
SELECT Query1.LOCATION, Sum(Query1.Cnt) AS SumOfCnt
FROM Query1
GROUP BY Query1.LOCATION;
 
Upvote 0
Its actually pretty easy to do it one query also (you can aggregate on a calculated field), i.e.
Code:
SELECT LOCATION, Sum(IIf([On Hand]<1,1,0)) AS Cnt
FROM Sheet1
GROUP BY LOCATION;
 
Upvote 0
Wouldn't
Rich (BB code):
select Location, count(*) from Sheet1
where [on hand] < 0
group by Location

Be simpler?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,040
Messages
6,128,454
Members
449,455
Latest member
jesski

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