Solved

Crosstab or Pivot Table without numbers

Posted on 2014-04-25
6
538 Views
Last Modified: 2014-04-26
I'm trying to create a crosstab query in MS Access that would show only character values instead of numbers as values.  The query is supposed to show a rating (e.g. H, M or L) as values for each risk (rows) and departments (columns).  The table driving this crosstab query doesn't have duplicate department/risk combination.  I haven't been able to do this with pivot tables/cross tab query because it only seem to allow numbers as values.  Any ideas?
0
Comment
Question by:eklin
[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
  • 3
  • 2
6 Comments
 
LVL 36

Expert Comment

by:PatHartman
ID: 40024154
Convert the values to strings in the base query.  Then in the crosstab choose min/max/first/last to select the value to display.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40024295
If you only have a single record for each combination of row/column headers, then you should be able to use "first" or "last" as the aggregation method for the cells that go into the crosstab.

If you have multiple values and you need to perform some preliminary operation to determine the rating across multiple records before you create the crosstab.

It would be much easier to address your question if you could provide some sample data and how you want your output to look, with an explanation of how each cell in the crosstab was calculated.
0
 

Author Comment

by:eklin
ID: 40024554
Pat - what I'm trying to do is avoid substituting the character values to numbers and then back.  It's too messy.  I'm trying to do this in one query.

Dale - thanks for the tip.  I've attached the sample data and desired results in the attached spreadsheet.  I'm hoping there is a way to do this through a query instead of using VBA.  We had a consultant code this in VBA before.  She converted the characters (high/medium/low) to numbers and then back to perform the crosstab but performance wise it is taking over 8hrs to process 7,500 rows of records, where I can do this manually with Excel in less than 1 hr.  In Excel, you can choose 2 values for the columns and it works nicely because the columns can be displayed in the desired order if you choose that field first.
Sample-Crosstab.xlsx
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 36

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40024677
I can't imagine why this is taking over 8 hours.  Even an inefficient loop with multiple DLookup()s shouldn't take that long.

This is what the query should look like.  I chose "First" as the Transform operator but if the data is unique as you say it is, then First/Last/Min/Max will all produce the same result as I mentioned in my first post.  

Requiring that the columns be in an order other than alphabetical means that you need an In() clause.  The danger with that is that your pivot is now constrained to ONLY the values listed in the In() clause.  If you add a new department, it will be ignored.  The up side of having the In() clause is that you always get a fixed set of columns which would make reporting easier.

TRANSFORM First(Table2.[Risk]) AS FirstOfRisk
SELECT Table2.[Risk Category]
FROM Table2
GROUP BY Table2.[Risk Category]
PIVOT Table2.[Department] In ("Sales","Accounting","IT","Administrative");

QBE view
0
 

Author Comment

by:eklin
ID: 40024936
Pat,  this is just what I needed.  Thanks!
0
 
LVL 36

Expert Comment

by:PatHartman
ID: 40024964
You're welcome.

PS - I used the wizard to build it.  Access has many useful wizards and this is one of them.  After I built the query, I switched to QBE view and removed the "totals" column since for a crosstab like this one it doesn't make sense given that there is nothing in the row to sum.  Although the wizard limits you to three columns as "Row Heading", you can modify the query after the wizard finishes to add more if you need them.  In your case we only needed one but I mention it because I want to make it clear that once the wizard is finished, the query is yours to modify.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

749 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