Counting column values

andrew_sheffer

New Member
Joined
Oct 25, 2004
Messages
2
I have a table with 45 columns(c1, c2, c3....) and about 200 rows (which are names). Each column has three possible values p,a,n/a. How can I get a count of values types per column?

Andy
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hello and welcome.

I managed to get your example to work by creating a new table which had just the one field (in my case I called it "possible") and three rows of data (i.e. "a", "p" & "n/a") - you may already have this table in your database (being the possible values for the 45 columns). It may also be possible to do this wihtout creating this table, but I set this up for simplicity purposes.

Create a new query, add the new table (with the 3 possible values) and the original table (with the 45 columns), do not link the tables, view totals, add the "possible" variable and the 45 columns to your query.

Change c1 to :

Field = 1 : IIf([c1]=[possible],[c1],Null)
Total = Count

Change c2 to :

Field = 2 : IIf([c2]=[possible],[c2],Null)
Total = Count

...and so on for the 45 columns.

Save and run.

HTH, Andrew. :)
 
Upvote 0

Forum statistics

Threads
1,221,826
Messages
6,162,192
Members
451,752
Latest member
majbizzaki

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