Solved

Access Query: flip from vertical to horizontal for a report

Posted on 2008-11-03
6
1,161 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now