Solved

Access Query: flip from vertical to horizontal for a report

Posted on 2008-11-03
6
1,167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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 250 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 250 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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, when working with VBA, learn some techniques for writing readable and easily maintained code.

635 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