How to properly use pivot/pivot enterprise

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
JohnyNeg
Participant
Posts: 3
Joined: Tue Aug 23, 2011 9:06 am

How to properly use pivot/pivot enterprise

Post by JohnyNeg »

I am in the process of transforming US census data so that it is conforming with my database format.

Starting format:

GEO_ID2 SUMLEVEL GEO_NAME B15002A_1_EST B15002A_2_EST B15002A_3_EST
107000 160 Birmingham city, Alabama 44000 20500 1017
121184 160 Dothan city, Alabama 30326 14155 577
135896 160 Hoover city, Alabama 37016 17453 171
137000 160 Huntsville city, Alabama 81467 39493 1441

Proposed Ending Format:

GEO_ID2 SUMLEVEL GEO_NAME MEASURE DIMENSION
107000 160 Birmingham city, Alabama 44000 B15002A_1_EST
107000 160 Birmingham city, Alabama 20500 B15002A_2_EST
107000 160 Birmingham city, Alabama 1017 B15002A_3_EST
121184 160 Dothan city, Alabama 30326 B15002A_1_EST
121184 160 Dothan city, Alabama 14155 B15002A_2_EST
121184 160 Dothan city, Alabama 577 B15002A_3_EST
135896 160 Hoover city, Alabama 37016 B15002A_1_EST
135896 160 Hoover city, Alabama 17453 B15002A_2_EST
135896 160 Hoover city, Alabama 171 B15002A_3_EST
137000 160 Huntsville city, Alabama 81467 B15002A_1_EST
137000 160 Huntsville city, Alabama 39493 B15002A_2_EST
137000 160 Huntsville city, Alabama 1441 B15002A_3_EST


1. I understand how to use the pivot stage to get the MEASURE column to transpose down the values.
2. What I do not know how to do and is crucial for what I need is how to treat the column headers as data so that i can transpose that as well along with the measures. The reason for needing this DIMENSION column is that it is an ID for how I need to retrieve each measure

Feel free to post any questions or comments if I need to give more information to make this more clear.

Thanks in advance
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Derive MEASURE as B15002A_1_EST,B15002A_2_EST,B15002A_3_EST
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
JohnyNeg
Participant
Posts: 3
Joined: Tue Aug 23, 2011 9:06 am

Post by JohnyNeg »

If I derive MEASURE from those values I will only get the values, what I need is the Column header to be pivoted down alongside the value. From my initial post with the way pivot works by default the proposed ending format would be lacking the last column DIMENSION.

@Ray - Thanks for the idea though, not sure I was as clear as I could have been with my initial post.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You need to add new fields with the column header values in them to pivot along with their associated data fields.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Surely it's enough that your other columns are your pivot keys?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
JohnyNeg
Participant
Posts: 3
Joined: Tue Aug 23, 2011 9:06 am

Post by JohnyNeg »

@chulett - That's what I was thinking I would have to do but wasn't sure if there was an automated way to do it. I just thought of something once I stepped away from the computer for a few minutes to clear my head so I will post back tomorrow whether or not it worked.

@ray - The other columns only give uniqueness to the location, my need for bringing down the column headers is that it will add more dimensions. Thus giving additional uniqueness for race, sex, and education attainment level (That is the information embedded in the column headers).

I apologize for my lack of proper terminology, I am new to the world of databases and picking it up as I go.
fmou
Participant
Posts: 124
Joined: Sat May 28, 2011 9:48 pm

Post by fmou »

what I need is the Column header to be pivoted down alongside the value
Have you looked at this?

Pivoting with an description
viewtopic.php?t=142442
Post Reply