473,378 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to Count Individual Items in a Drop-down list

4
Hi All,

I have a drop down list with the values:
Contacted, Not Interested
Qualified, Opted Out
Screened, Waiting on Paperwork
Enrolled

I would like to run a query to generate a report that totals the number for each value ie how many people I have "Contacted, not interested," how many "qualified, opted out" etc.

For other drop down menus with just "yes" or "no" options (for example "contacted - yes or no"), I have used
=Count(IIf([Contacted]= yes, 1, null)) to total my responses. I don't understand how to do something similar for multiple values. Any help would be much appreciated!
Jun 4 '14 #1
7 4871
jimatqsi
1,271 Expert 1GB
Using and extending your own methodology, you could do like this:
Expand|Select|Wrap|Line Numbers
  1. Select Count(IIf([Contacted]= yes, 1, null)) as Contacted, iif([ContactResult]="Contacted, Not Interested",1,null) as CNI, iif([ContactResult]="Qualified, Opted Out",1,null) as QOO, 
  2. iif([ContactResult]="Screened, Waiting on Paperwork",1,null) as SWOP, iif([ContactResult]="Enrolled",1,null) as ENR ...
  3.  
I believe that should give you counts for each of the values listed. I've made the assumption that the value you're counting is called "ContactResult"

Jim
Jun 4 '14 #2
twinnyfo
3,653 Expert Mod 2GB
balto1,

Why not simply use an aggregate query, based on the dropdown values, with a Count on the Customer ID? jimatqsi's option would work if your dropdown values never changed and you wanted horizontal values. However, if you change the values of your dropdown, you would have to keep adding to the width of your query.

It just depends on how you want to manipulate your data afterwards.
Jun 9 '14 #3
balto1
4
Sorry for not responding sooner, I got caught up with things. Jim atqsi I did try your suggestion but kept an error message saying it contains invalid syntax, no matter how I try to change it.

twinnyfo could you please expand on how I to run an aggregate query - this sounds like exactly what I'm looking for!

Thanks!
Jun 10 '14 #4
twinnyfo
3,653 Expert Mod 2GB
balto1,

When you create your Query, under the Query Tools Design Menu, there should be a Greek Sigma, with "Totals" underneath it. Click that, which will create an aggregate query.

Then, when you add your fields to the Query, for the field showing your contact information, there will be a "Total" row in the query designer. Select "Group By".

Then, add any other field from your table, but preferably the Customer ID (if you have one) because it's good practice to count the key field of a Table as a unique identifier. In the Query designer window, on the "Totals" Row, select "Count".

When you execute your query, you should have the following:

Expand|Select|Wrap|Line Numbers
  1. Customer Status                 CountOfCustomerID
  2. Contacted, Not Interested       7
  3. Qualified, Opted Out            12
  4. Screened, Waiting on Paperwork  23
  5. Enrolled                        48
I hope this makes sense. It's hard to teach in a one-sided post without showing and demonstrating.

Please let me know if you need any additional assistance!
Jun 10 '14 #5
balto1
4
So simple and exactly what I wanted; I don't know why I didn't figure this out sooner. Thank you SO much :D
Jun 11 '14 #6
balto1
4
One more question actually. If I have two or more field that I would like to count in a query using this method, for example I have "Recruitment Status" which has a drop down menu of answers and then I also have "Enrollment Status" with a different drop down menu of choices.

If I am counting my ID, and grouping by "Recruitment Status" is there a way to also separately count "Enrollment Status" in the same query? If i just add "Enrollment Status" into the query, its keeps the same count from "Recruitment Status." I hope this makes sense.Thanks!
Jun 11 '14 #7
twinnyfo
3,653 Expert Mod 2GB
If you add Enrolled Status to your Query and Group by that Field, you will get something like this:

Expand|Select|Wrap|Line Numbers
  1. Recruitment Status               Enrollment Status   CountOfCustomerID
  2. Contacted, Not Interested        Not Enrolled        23
  3. Contacted, Not Interested        Enrolled            48
  4. Qualified, Opted Out             Not Enrolled        15
  5. Qualified, Opted Out             Enrolled            17
Aggregate queries can be very useful when you have different sets of datat like this, but they can also be tricky. It took me a lot of playing around with them to get good at making very complex queries that provided exactly what I wanted.

This should be a good place for you to start. Do some experimenting with this and let us know how it turns out.
Jun 11 '14 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Frawls | last post by:
Hi, This is concerned with System.Web.UI.WebControls.DropDownList I am having problems creating a method which will remove list items from a preloaded dropdownlist. This dropdown is loaded...
3
by: Kay | last post by:
Hello, I have two list boxes on my form, one initially displays blank, and through javascript it is possible to move items from one box to another, this works fine, I followed an article titled...
6
by: San Smith | last post by:
I have a dropdown list box with list of item. When I read the data from database I want to display that value(one of the item in the drop down box) in the dropdown list box. How to do that in a...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
3
by: Big Dave | last post by:
I know it's been asked a million times before, but I still can't seem to find an answer that works. I've got a dropdown list in the footer template of a datagrid. The dropdown list databinds,...
1
by: JIM.H. | last post by:
Hello, I usee this to find string sD in drop down list and select the value. dllSP.SelectedIndex = dllSP.Items.IndexOf(dllSP.Items.FindByText(sD); Can I get FindByText work with wildcards? So...
2
by: tshad | last post by:
I am trying to add a different color to some of the rows in my dropdown list and this is how it is suggested to do this in a couple of articles. I have a DropDownList call PayDates and I was...
2
by: mervyntracy | last post by:
Hi There, I have recently started coding in asp.net (just 2 and a half days now). I am writing a simple test app that gets data from a data base and displays the value perfectly in the drop down...
3
by: John | last post by:
I have two dropdown lists that I have bound to a datatable and set the DataTextField and DataValueField for. Both lists show the values I expect from the database. However, when I need to access...
5
by: Bob Lee | last post by:
Access 2010. I have a drop down list with "Male" or "Female" as the choice. I wish to count the number of Males and the number of Females to show on a report. The Field name is which is stored in a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.