Hi, I am using Access 2007 and need help creating a query. If this is crazy long, sorry! I figure the more details the better understanding. I am not a programmer--I hope someone will help.
I need to know how to collapse/summarize/roll up non-numeric data into a single row that shares a characteristic/value. What I want is like a crosstab query because I want unique cell values from different rows pivoted/displayed in columns along one row for that shared/common value. However, my data isn't numeric and it requires alpha column headings, which crosstabs prohibit.
THE DATA:
- Badge_code 24 is produced in 3 locations: 110, 210, and 320 (represents Chicago, Rockford, and St. Louis)
- Badge_code B9 in 2 locations: 110, and 280 (Chicago and Peoria)
- Badge_code C1 in 3 locations: 200 and 210 (Indianapolis and Rockford)
Each badge_code-location combination is in a separate row, 8 rows total. The number of badge codes can/will grow.
THE QUERY I'VE TRIED:
Count(tbl_BadgeType.Badge_type_number) AS CountOfBadge_type_number
SELECT tbl_BadgeType.Badge_code
FROM tbl_BadgeType
GROUP BY tbl_BadgeType.Badge_code
PIVOT tbl_BadgeType.Location_production;
Badge_type_number is the primary key used to id each badge code-location use combo.
RESULT:
Badge Code 110 200 210 280 320
24 1 1 1
B9 1 1
C1 1 1
The column headings are numeric and can't be changed to location names in crosstabs and I want a "Yes" instead of a "1". (Obviously, they're 1s because it's a count function in the crosstab, which I don't really need...)
DESIRED RESULT:
Badge Code Chicago Indianapolis Rockford Peoria St. Louis
24 Yes No Yes No Yes
B9 Yes No No Yes No
C1 No Yes Yes No No
PROBLEM/QUESTIONS:
- A crosstab query in its strictest sense is not quite what I need, but I do not know how to simulate its "roll up" effect. It's the difference between 6 pages of obscurity and 1 page of useful clarity.
- If a crosstab is the way to go, then I can't figure out how to get the "1" values to be displayed as a "Yes". I've used IIF statements in other queries and reports to "translate" 1/0 values to "Yes/No" but can't figure out where to put the IIFs in this query or its report.
Is this making sense? Am I asking too much? Is there hope for me? :^)