Query Count

QandAdam

New Member
Joined
Jan 12, 2019
Messages
30
This is hopefully a simple one.

How can I count records based on criteria? So it would be a count of 'Active' ('Status' Field) for each 'Group'.

I'm looking to go from something like this:
GroupRecordIDStatus
ABC0001Active
ABC0002Closed
ABC0003Active
DEF0004Active

<tbody>
</tbody>
etc....

To this:
GroupActive Records
ABC13
DEF25

<tbody>
</tbody>

I've tried the below as a field in the query but it returns the wrong numbers:
[FONT=&quot]
Code:
[/FONT][/COLOR][COLOR=#2F2F2F][FONT=&quot]=DCount("[Group]", "tblRecords", "[SalesStatus] = 'Active'")[/FONT][/COLOR][COLOR=#2F2F2F][FONT=&quot]

[/FONT]
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
This is really easy to do with an Aggregate (Totals) Query.
Create a new query adding all three of those fields.
Click on the Totals button in the menu of the Query Builder (look like a Sigma).
Under the "RecordID" field, change the new Totals row value from "Group By" to "Count".
Under the "Status" field, change the new Totals row value from "Group By" to "Where".
Add the word "Active" on the Criteria row of the "Status" field.
View your results.

You may wish to read up more on Aggregate/Totals queries to get a better understanding of how they work. You can find lots of articles and tutorials with a Google search.
 
Upvote 0
This is really easy to do with an Aggregate (Totals) Query.
Create a new query adding all three of those fields.
Click on the Totals button in the menu of the Query Builder (look like a Sigma).
Under the "RecordID" field, change the new Totals row value from "Group By" to "Count".
Under the "Status" field, change the new Totals row value from "Group By" to "Where".
Add the word "Active" on the Criteria row of the "Status" field.
View your results.

You may wish to read up more on Aggregate/Totals queries to get a better understanding of how they work. You can find lots of articles and tutorials with a Google search.

AMAZING! That is easy! Thanks for the help and advice
 
Upvote 0
You are welcome.
Glad I was able to help!
:)
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

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