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.
10 1525
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?
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;
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.
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
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. - SELECT 1 As TempVal,
-
Sum(IIf([Workshop1]=[TempVal],[TempVal],0)) AS CountWk1,
-
Sum(IIf([Workshop2]=[TempVal],[TempVal],0)) AS CountWk2,
-
Sum(IIf([Workshop3]=[TempVal],[TempVal],0)) AS CountWk3,
-
Sum(IIf([Workshop4]=[TempVal],[TempVal],0)) AS CountWk4
-
FROM people
-
UNION
-
SELECT 2 AS TempVal,
-
Sum(IIf([Workshop1]=[TempVal],[TempVal],0)) AS CountWk1,
-
Sum(IIf([Workshop2]=[TempVal],[TempVal],0)) AS CountWk2,
-
Sum(IIf([Workshop3]=[TempVal],[TempVal],0)) AS CountWk3,
-
Sum(IIf([Workshop4]=[TempVal],[TempVal],0)) AS CountWk4
-
FROM people
-
UNION
-
SELECT 3 AS TempVal,
-
Sum(IIf([Workshop1]=[TempVal],[TempVal],0)) AS CountWk1,
-
Sum(IIf([Workshop2]=[TempVal],[TempVal],0)) AS CountWk2,
-
Sum(IIf([Workshop3]=[TempVal],[TempVal],0)) AS CountWk3,
-
Sum(IIf([Workshop4]=[TempVal],[TempVal],0)) AS CountWk4
-
FROM people
-
UNION
-
SELECT 4 AS TempVal,
-
Sum(IIf([Workshop1]=[TempVal],[TempVal],0)) AS CountWk1,
-
Sum(IIf([Workshop2]=[TempVal],[TempVal],0)) AS CountWk2,
-
Sum(IIf([Workshop3]=[TempVal],[TempVal],0)) AS CountWk3,
-
Sum(IIf([Workshop4]=[TempVal],[TempVal],0)) AS CountWk4
-
FROM people
-
UNION
-
SELECT 5 AS TempVal,
-
Sum(IIf([Workshop1]=[TempVal],[TempVal],0)) AS CountWk1,
-
Sum(IIf([Workshop2]=[TempVal],[TempVal],0)) AS CountWk2,
-
Sum(IIf([Workshop3]=[TempVal],[TempVal],0)) AS CountWk3,
-
Sum(IIf([Workshop4]=[TempVal],[TempVal],0)) AS CountWk4
-
FROM people;
PS. Yes Mary, I see now why you chose this approach.
MMcCarthy 14,534
Recognized Expert Moderator MVP
Hi Adrian
Good expansion on my solution. Should work well.
Mary
[quote=NeoPa] - SELECT 1 As TempVal,
-
.
-
.
-
.
-
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.
MMcCarthy 14,534
Recognized Expert Moderator MVP
[quote=Killer42]
- SELECT 1 As TempVal,
-
.
-
.
-
.
-
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: -
-
SELECT 1 As TempVal,
-
Count(DLookup("[Workshop1]","people","[Workshop1]=" & [TempVal]) AS CountWk1,
-
Count(DLookup("[Workshop2]","people","[Workshop2]=" & [TempVal]) AS CountWk2,
-
Count(DLookup("[Workshop3]","people","[Workshop3]=" & [TempVal]) AS CountWk3,
-
Count(DLookup("[Workshop4]","people","[Workshop4]=" & [TempVal]) AS CountWk4
-
UNION
-
-
etc........
-
-
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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)
...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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: 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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |
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 ...
| |