473,473 Members | 1,513 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how do I chart the number of distinct occurances of several workshops?

1 New Member
Hi,
How do I chart or calculate a report to count the distinct occurances of the values 1 to 5 for lets say 10 workshops. I have the following table in MS Access:
ID Workshop1 Workshop2 Workshop3 Workshop4 ....
1 ..... 3 ............... 2 ..................4 .................1
2 ......2 .................2 ..................2.................5
3..... 2 .................1 ...................5.................5
4 ..... 3..................3.................. 4 ............... 3
......etc

I counted the number of occurances for one workshop:
SELECT DISTINCT people.workshop1, Count(people.workshop1) AS CountOfworkshop1 FROM people GROUP BY people.workshop1;
But I need to chart it for about 10 workshops in the one graph/chart in MS Access.
thanks.
Nov 6 '06 #1
10 1525
Killer42
8,435 Recognized Expert Expert
Hi,
How do I chart or calculate a report to count the distinct occurances of the values 1 to 5 for lets say 10 workshops. I have the following table in MS Access:
ID Workshop1 Workshop2 Workshop3 Workshop4 ....
1 ..... 3 ............... 2 ..................4 .................1
2 ......2 .................2 ..................2.................5
3..... 2 .................1 ...................5.................5
4 ..... 3..................3.................. 4 ............... 3
......etc

I counted the number of occurances for one workshop:
SELECT DISTINCT people.workshop1, Count(people.workshop1) AS CountOfworkshop1 FROM people GROUP BY people.workshop1;
But I need to chart it for about 10 workshops in the one graph/chart in MS Access.
thanks.
Just a question for clarification - are these 10 "workshops" 10 fields (or groups of fields) in a table? Or 10 separate tables? Or 10 records in a table? From the layout shown, I'm guessing the first option?
Nov 7 '06 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi,
How do I chart or calculate a report to count the distinct occurances of the values 1 to 5 for lets say 10 workshops. I have the following table in MS Access:
ID Workshop1 Workshop2 Workshop3 Workshop4 ....
1 ..... 3 ............... 2 ..................4 .................1
2 ......2 .................2 ..................2.................5
3..... 2 .................1 ...................5.................5
4 ..... 3..................3.................. 4 ............... 3
......etc

I counted the number of occurances for one workshop:
SELECT DISTINCT people.workshop1, Count(people.workshop1) AS CountOfworkshop1 FROM people GROUP BY people.workshop1;
But I need to chart it for about 10 workshops in the one graph/chart in MS Access.
thanks.
Unfortunately, there is no easy way to do this. The following will cover 4 workshop fields you will need to adapt it to cover 10.

SELECT "1" As TempVal,
Sum(IIf([workshop1]=1,1,0)) AS CountWk1,
Sum(IIf([workshop2]=1,1,0)) AS CountWk2,
Sum(IIf([workshop3]=1,1,0)) AS CountWk3,
Sum(IIf([workshop4]=1,1,0)) AS CountWk4,
FROM people
UNION
SELECT "2" AS TempVal,
Sum(IIf([workshop1]=2,1,0)) AS CountWk1,
Sum(IIf([workshop2]=2,1,0)) AS CountWk2,
Sum(IIf([workshop3]=2,1,0)) AS CountWk3,
Sum(IIf([workshop4]=2,1,0)) AS CountWk4
FROM people
UNION
SELECT "3" AS TempVal,
Sum(IIf([workshop1]=3,1,0)) AS CountWk1,
Sum(IIf([workshop2]=3,1,0)) AS CountWk2,
Sum(IIf([workshop3]=3,1,0)) AS CountWk3,
Sum(IIf([workshop4]=3,1,0)) AS CountWk4
FROM people
UNION
SELECT "4" AS TempVal,
Sum(IIf([workshop1]=4,1,0)) AS CountWk1,
Sum(IIf([workshop2]=4,1,0)) AS CountWk2,
Sum(IIf([workshop3]=4,1,0)) AS CountWk3,
Sum(IIf([workshop4]=4,1,0)) AS CountWk4
FROM people
UNION
SELECT "5" AS TempVal,
Sum(IIf([workshop1]=5,1,0)) AS CountWk1,
Sum(IIf([workshop2]=5,1,0)) AS CountWk2,
Sum(IIf([workshop3]=5,1,0)) AS CountWk3,
Sum(IIf([workshop4]=5,1,0)) AS CountWk4
FROM people;
Nov 7 '06 #3
NeoPa
32,556 Recognized Expert Moderator MVP
You could look at CrossTab queries.
Very inexperienced in those myself, but this is worth a look I think.
Nov 7 '06 #4
MMcCarthy
14,534 Recognized Expert Moderator MVP
You could look at CrossTab queries.
Very inexperienced in those myself, but this is worth a look I think.
I tried it first as a crosstab query but because of the table structure I don't think it will work.

But as you say worth another look if anyone has any suggestions.

Mary
Nov 7 '06 #5
NeoPa
32,556 Recognized Expert Moderator MVP
I'm not positive this will work, but if it does, it should make it a little easier to amend.
I tried creating a UNION query with just the TempVals first, but it insisted on a FROM clause.
Expand|Select|Wrap|Line Numbers
  1. SELECT 1 As TempVal, 
  2. Sum(IIf([Workshop1]=[TempVal],[TempVal],0)) AS CountWk1,
  3. Sum(IIf([Workshop2]=[TempVal],[TempVal],0)) AS CountWk2,
  4. Sum(IIf([Workshop3]=[TempVal],[TempVal],0)) AS CountWk3,
  5. Sum(IIf([Workshop4]=[TempVal],[TempVal],0)) AS CountWk4
  6. FROM people
  7. UNION
  8. SELECT 2 AS TempVal,
  9. Sum(IIf([Workshop1]=[TempVal],[TempVal],0)) AS CountWk1,
  10. Sum(IIf([Workshop2]=[TempVal],[TempVal],0)) AS CountWk2,
  11. Sum(IIf([Workshop3]=[TempVal],[TempVal],0)) AS CountWk3,
  12. Sum(IIf([Workshop4]=[TempVal],[TempVal],0)) AS CountWk4
  13. FROM people
  14. UNION
  15. SELECT 3 AS TempVal, 
  16. Sum(IIf([Workshop1]=[TempVal],[TempVal],0)) AS CountWk1,
  17. Sum(IIf([Workshop2]=[TempVal],[TempVal],0)) AS CountWk2,
  18. Sum(IIf([Workshop3]=[TempVal],[TempVal],0)) AS CountWk3,
  19. Sum(IIf([Workshop4]=[TempVal],[TempVal],0)) AS CountWk4
  20. FROM people
  21. UNION
  22. SELECT 4 AS TempVal,
  23. Sum(IIf([Workshop1]=[TempVal],[TempVal],0)) AS CountWk1,
  24. Sum(IIf([Workshop2]=[TempVal],[TempVal],0)) AS CountWk2,
  25. Sum(IIf([Workshop3]=[TempVal],[TempVal],0)) AS CountWk3,
  26. Sum(IIf([Workshop4]=[TempVal],[TempVal],0)) AS CountWk4
  27. FROM people
  28. UNION
  29. SELECT 5 AS TempVal, 
  30. Sum(IIf([Workshop1]=[TempVal],[TempVal],0)) AS CountWk1,
  31. Sum(IIf([Workshop2]=[TempVal],[TempVal],0)) AS CountWk2,
  32. Sum(IIf([Workshop3]=[TempVal],[TempVal],0)) AS CountWk3,
  33. Sum(IIf([Workshop4]=[TempVal],[TempVal],0)) AS CountWk4
  34. FROM people;
PS. Yes Mary, I see now why you chose this approach.
Nov 8 '06 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi Adrian

Good expansion on my solution. Should work well.

Mary
Nov 8 '06 #7
Killer42
8,435 Recognized Expert Expert
[quote=NeoPa]
Expand|Select|Wrap|Line Numbers
  1. SELECT 1 As TempVal, 
  2. .
  3. .
  4. .
  5. FROM people;
No offence intended NeoPa, but SQL syntax sure forces some silly-looking and long-winded solutions on us at times... :)
On the plus side, I suppose that shows how flexible it is.
Nov 8 '06 #8
MMcCarthy
14,534 Recognized Expert Moderator MVP
[quote=Killer42]
Expand|Select|Wrap|Line Numbers
  1. SELECT 1 As TempVal, 
  2. .
  3. .
  4. .
  5. FROM people;
No offence intended NeoPa, but SQL syntax sure forces some silly-looking and long-winded solutions on us at times... :)
On the plus side, I suppose that shows how flexible it is.
It requires the FROM people because it is referencing the Workshop1, Workshop2, etc.

You could write it as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT 1 As TempVal, 
  3. Count(DLookup("[Workshop1]","people","[Workshop1]=" & [TempVal]) AS CountWk1,
  4. Count(DLookup("[Workshop2]","people","[Workshop2]=" & [TempVal]) AS CountWk2,
  5. Count(DLookup("[Workshop3]","people","[Workshop3]=" & [TempVal]) AS CountWk3,
  6. Count(DLookup("[Workshop4]","people","[Workshop4]=" & [TempVal]) AS CountWk4
  7. UNION
  8.  
  9. etc........
  10.  
  11.  
Nov 8 '06 #9
Killer42
8,435 Recognized Expert Expert
It requires the FROM people because it is referencing the Workshop1, Workshop2, etc. ...
Oh, I wasn't referring to the FROM specifically. It was just a comment about SQL in general. Like having to repeat big long functions in the selection criteria and the fields to be returned, that sort of thing.
Nov 8 '06 #10
MMcCarthy
14,534 Recognized Expert Moderator MVP
Oh, I wasn't referring to the FROM specifically. It was just a comment about SQL in general. Like having to repeat big long functions in the selection criteria and the fields to be returned, that sort of thing.
Totally agree with you. Would be great if we could pass multiple parameters to functions and get multiple returns. I suppose in theory if you redesigned the function with a variant array as a parameter and a variant array as a return you could get multiple values but SQL won't then allow you to create multiple Aliases for the field values.

Mary
Nov 8 '06 #11

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

Similar topics

17
by: keith | last post by:
I am trying to get a exact count of different distinct entries in an Access column. At first, I was trying to work with three columns, but I've narrowed it down to one to simplify it. I've searched...
22
by: PeteCresswell | last post by:
I've been to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mschrt/html/vbobjtitleobject.asp, but still don't have a clue. For example, I've got a chart object namde...
1
by: rkbnair | last post by:
I created a pie chart in an aspx. However, how can I display the data in the piechart itself in the right location? The code is as follows: (Please see the definition of float x and float y) ...
0
by: KurtEK | last post by:
I have several charts on a workbook sheet. Depending on which button object is "pressed" a chart is copied from location a to location b. I now want to delete the copy of the chart and copy another...
0
by: Wayne | last post by:
I am charting data from a query that consists of a Date/Time field and a Number field. The Date/Time field is the x scale on my chart. Sometimes data is collected from different times during the...
14
by: Haines Brown | last post by:
Genealogists often display their data as an ascending or descending chart, and for presentation on the web usually prepare a PDF file or HTML table. I was interested in a pure CSS solution without...
7
by: John | last post by:
I have a table with amongst others 2 fields: DateIn and DateOut. The idea is to make a chart that shows the average number of days it takes for a request to be answered. I'm planning to make a...
1
by: jackspam | last post by:
I need help on getting started with a dice program that will output as many random numbers from 1 to 6 and as many rolls as the user requests, and then how many times each number shows up from the...
1
by: drwigginton | last post by:
I have created several bar charts in MS Access using query results to provide the data for the chart. I added data tables to the charts to show the actual values. My problem is that one of the fields...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.