Transpose Columns to Rows Query (1 Viewer)

mrszw

Registered User.
Local time
Today, 01:09
Joined
Apr 9, 2009
Messages
11
Hi, i am encountering some problems and need help/suggestions on how to do this transpose. Basically, i wish to transpose the following table but is lost on how to achieve it in excel or using access queries. Would appreciate any help.

Original


Desired output
 

Attachments

  • transpose.xls
    17.5 KB · Views: 1,532

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:09
Joined
Aug 30, 2003
Messages
36,124
In Access you'd need a UNION query:

SELECT ID, Group, "Christian" AS Person, Christian
FROM TableName
WHERE Christian Is Not Null
UNION ALL
SELECT ID, Group, "Johnny" AS Person, Johnny
FROM TableName
WHERE Johnny Is Not Null
...
 

mrszw

Registered User.
Local time
Today, 01:09
Joined
Apr 9, 2009
Messages
11
thanks pabaldy! works great!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:09
Joined
Aug 30, 2003
Messages
36,124
No problem; welcome to the site by the way!
 

sgundlac

New member
Local time
Today, 04:09
Joined
Aug 8, 2013
Messages
3
Hi.
I have a similar question for transposing columns to rows using the Union All qry. I created the union qry to include all the columns (Christian, Johnny, Steve). However sometimes my data only has some but not all of the columns (example only Christian and Steve), and when I run the union qry I get a message box "Enter Parameter Value"" looking for the column Johnny. Is there a way to create VBA code to map the original data with only Christian and Steve into a normalized table with all 3 fields- Christian, Johnny, Steve)?
Thanks for your help! I've been going crazy trying to figure this out.
 

Users who are viewing this thread

Top Bottom