Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access Query: flip from vertical to horizontal for a report

Posted on 2008-11-03
6
Medium Priority
?
1,170 Views
Last Modified: 2013-11-28
Access 2003
Query, Report

Hello,

I'm trying to take information from a query and flip it from vertical to horizontal in a report. I start with this query:

StaffingGroup          PayGrade          CountOfPayGrade
Clerical                    1                       1
Clerical                    2                       1
Clerical                    3                       1
Sales                       1                       2
Sales                       2                      11
Management           1                      2



And then want to represent it in a report like this:

StaffingGroup      PayGrade 1      PayGrade 2      PayGrade 3
Clerical                1                      1                      1
Sales                   2                      11                    0
Management       2                      0                      0


My first thought is to rotate the information in a query first and then pull from that query to make the report. However, I can't figure out how to rotate the query to show the information in a horizontal format.  Thanks.
0
Comment
Question by:BradleyOnTheRoad
  • 2
  • 2
  • 2
6 Comments
 
LVL 17

Expert Comment

by:aflockhart
ID: 22867930
Set up a Crosstab Query from your data.

Staffing group will be a row heading
Pay Grade wil be a column heading
ANy field that always has a value (Paygrade could be used) is the data value.

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22873779
BradleyOnTheRoad,

I tried this as a crosstab with both fields, and neither relly gave me what you are loking for.

It it possible to see the Raw data *before* you got: "CountOfPayGrade"
?

JeffCoachman
0
 

Author Comment

by:BradleyOnTheRoad
ID: 22876460
 boag 2000
                 <!--[if gte mso 9]>   Normal  0      false  false  false                     MicrosoftInternetExplorer4 <![endif]--><!--[if gte mso 9]>  <![endif]--><!--[if gte mso 10]><![endif]-->StaffingGroup         PayGrade        
Clerical                   1                      
Clerical                   2                      
Clerical                   3                      
Sales                       1                      
Sales                       1                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Management           1                      
Management           1                      
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:BradleyOnTheRoad
ID: 22876476
Let's try that again.

StaffingGroup         PayGrade        
Clerical                   1                      
Clerical                   2                      
Clerical                   3                      
Sales                       1                      
Sales                       1                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Sales                       2                      
Management           1                      
Management           1                      
0
 
LVL 17

Accepted Solution

by:
aflockhart earned 1000 total points
ID: 22876562
Did you try it with a crosstab query based on your original data ?


The SQL that it generates will be something like this:  (change to include your table/field names)

TRANSFORM Count(Staff.ID) AS CountOfID
SELECT Staff.StaffingGroup, Count(Staff.ID) AS [Total Of ID]
FROM Staff
GROUP BY Staff.StaffingGroup
PIVOT Staff.PayGrade;


or if you don't want overall totals on each row:


TRANSFORM Count(Staff.ID) AS CountOfID
SELECT Staff.StaffingGroup
FROM Staff
GROUP BY Staff.StaffingGroup
PIVOT Staff.PayGrade;



0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 1000 total points
ID: 22882686
BradleyOnTheRoad,

Thanks,
As you can see, the *raw* data can easily be summarized using one of aflockhart's suggestions.

The first data structure you posted was already summarized, making this difficult.
;-)

JeffCoachman
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question