Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Issues with Counting (DCount, Criteria, etc)

$
0
0
Hello,

I have a table that I would like to perform an Access query on, preferably avoiding VBA. Using Access 2010.

I have a table of records, with surrounding quantitative and qualitative data. What I'd like to do is count the total number of records for each business division, and then within each business division the number of records fulfilling two different criteria, and then perform a calculation on sums of values within records in each business division.

For instance, I have store A and B. Store A made 100 sales (# of records), and store B made 200 sales. Of those 100 and 200 sales, 30 and 40 sales respectively have a value of "Yes" in a 'Yes' or 'No' column. Of those 100 and 200 sales, 70 and 90 have a sale price that is neither blank or non-zero (not necessary to know how many of the 70 and 90 had yes/no). Lastly, I'd like to sum up the total value of sales over those 100 records and 200 records and subtract the total value of another variable. Let's say the difference is 300 and 400.

Outcome should be:

A / 100 / 30 / 70 / 300
B / 200 / 40 / 90 / 400

I tried using a standard Query, where I grouped by store name. Then I tried to add query columns with "Total: Count" for the other fields, but when I add Criteria values such as {<>"No"} or {>0} there's a "Data type mismatch in Criteria expression." If I include a Total: Group By column I can add the filter, but that adjusts the filter for my entire query (it will filter out all the "No" and non-zero records)

I tried DCount, where I entered a column with something like the following in the top column:

DCount("Sale Price","tblSales", "[Sale Price] > 0")

But that told me the total number of non-sales over all stores, not just A and B.

Not really sure what to do at this point. I could see myself creating multiple queries and building one query to sample all of them, but this record table is massive. Advice? Any additional info I can provide?

Viewing all articles
Browse latest Browse all 13329

Trending Articles