Creating a cross tab query for a report with multiple values for a column

Hi Everyone,

I am trying to wrap my head around a reporting problem.  I suspect my data may not be corectly organized, but I could use your help.

I have a payroll database that houses the usual suspects...employee name, emp number, date worked, type of hours worked, hours, bonus, cash value, ect.

I will simplify my table for conversation here.  My table consists of employee #, pay type, hours, dollars.  Every data entry has Emp #, pay type (regular, OT, comission, bonus), hours (corresponding to regular or OT pay types), or Dollars (corresponding to commission or bonus). I couldn't combine hours and dollars together as they are different field types.

How can I develop a cross tab query and report to detail out
Row Headings: Employee number
Column Headings: Pay Types
Values: Hours under the corresponding type, and Dollars under the corresponding type.

Cross tab queries will only allow one value set.  Can anyone give me an idea how to construct this report?  I attached a file with a mock up of the data and how I'd like to structure the report.

Thanks!
MC


mock.xlsx
MCaliebeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
test this query


SELECT yrTable.[Emp ID], Sum(IIf([Pay Type]="Regular",[Hours],0)) AS Regular, Sum(IIf([Pay Type]="Regular Overtime",[Hours],0)) AS [Regular Overtime], Sum(IIf([Pay Type]="Bonus",[Dollars],0)) AS Bonus, Sum(IIf([Pay Type]="Commission",[Dollars],0)) AS Commission
FROM yrTable
GROUP BY yrTable.[Emp ID];


change table/field name accordingly
0
MCaliebeAuthor Commented:
Thanks for your query suggestion.

I should clarify that my Pay Tpes can grow or shrink depending on what selection is used that week.  For instance, Commission may not be paid every week, however we might have some sick time and vacation time to record.  Cross tab is the only way I know to use a query result for column names.  Unless there is a way to make a dynamic report that will populate the headers based on what is found a the time of query execution.

Thanks,
MC
0
Jeffrey CoachmanMIS LiasonCommented:
Just to clarify...

If your ultimate goal is to use a crosstab query as the source for a report, then this may not be easy.

A report will "Hardcode" the fields.

A cross tab query generates the specif fields based on the source data.

So you may get "Field not found" errors when you run the report.

If this requirement is a deal-breaker then you can look into using a solution like this:
http://support.microsoft.com/kb/328320 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.