count function in a report

R

Roy

I am trying to summorize 3 categorys from my table in a report. The data
type in the table is a number (Field name [CategoryID]). What I need is to
get the total number of each categor (1,2,3). There is a potential that 1 or
more of these categories will be null, which I want a "0" to be visable. The
report will look something like this;

Category Summary Total
Minor 2
Major 3
OFI 0

I am new to using access so any help will be gratefull.

Thank you
 
K

KARL DEWEY

Try this --
SELECT IIF([CategoryID] =1,"Major", IIF([CategoryID] = 2, "Minor",
IIF([CategoryID] = 3,"Something", "OFI"))) AS [Category Summary],
Count(IIF([CategoryID] Is Null, "", [CategoryID])) AS Total
FROM [YourTable];
 
K

KARL DEWEY

I misread your post, try this --
Create a table named CategoryList with data --
CategoryID Title
1 Major
2 Minor
3 OFI
Then use this query --
TRANSFORM Count(YourTable.CategoryID) AS CountOfID
SELECT CategoryList.Title AS [Category Summary]
FROM CategoryList LEFT JOIN YourTable ON CategoryList.CategoryID =
YourTable.CategoryID
GROUP BY CategoryList.Title
PIVOT "Total";

--
KARL DEWEY
Build a little - Test a little


KARL DEWEY said:
Try this --
SELECT IIF([CategoryID] =1,"Major", IIF([CategoryID] = 2, "Minor",
IIF([CategoryID] = 3,"Something", "OFI"))) AS [Category Summary],
Count(IIF([CategoryID] Is Null, "", [CategoryID])) AS Total
FROM [YourTable];

--
KARL DEWEY
Build a little - Test a little


Roy said:
I am trying to summorize 3 categorys from my table in a report. The data
type in the table is a number (Field name [CategoryID]). What I need is to
get the total number of each categor (1,2,3). There is a potential that 1 or
more of these categories will be null, which I want a "0" to be visable. The
report will look something like this;

Category Summary Total
Minor 2
Major 3
OFI 0

I am new to using access so any help will be gratefull.

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top