Desired Format Pivot

Hello ,
Current Format shows the data structure it’s in currently.  Somehow, someway it has to be pivoted to get it in the format I need where time stamp columns transform to the rows instead.  The format I need is shown in Desired Format sheet. The fastest way to o this on 35000-40000 rows
Thanks
pivotDesired.xlsx
RayneAsked:
Who is Participating?
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Connect With a Mentor Microsoft MVP ExcelCommented:
Hello,

this can be done with a "reverse pivot", but first we need to change the source a bit:

Insert a column after column B, put a label in row 2 and in row 3 enter the formula

=A3&"-"&B3

Copy down. Now for the reverse Pivot.

1.  click a cell in the table and then use Alt - D - P to bring up the good, old Pivot Table wizard (yes, it's still there!)
2. in the first step, click "Multiple consolidation ranges" and Next
3. in Step 2a click "I will create the page fields" and Next
4. in Step 2b select the range, starting with the newly inserted column. Do not include columns A and B.  -- then click Next
5. in Step 3 select "new Worksheet" and click Finish

You will now see a pivot table. In the Pivot table field pane, drag all the fields from the Column Labels and the Row Labels areas back up into the field list. You will see the pivot table reduced to one cell with a number and a label above.

Double-click the number.

This will create a sheet with the raw data. Now you only need to split the previously concatenated columns A and B. Insert a new column between A and B and perform a Text to Columns on column A, using the "-" as the delimiter.

cheers, teylyn
0
 
SteveConnect With a Mentor Commented:
the following code will do exactly what is required in the example workbook

Sub Normalise()
Dim myRng As Range
Dim myArr()
Dim x as long
Dim y as long
Dim z as long

Set myRng = ThisWorkbook.Sheets("Current").Range("A2:CX108")
Z = 1
For x = 2 To 107
    For y = 1 To 100
        ReDim Preserve myArr(1 To 4, 1 To Z)
        myArr(1, Z) = myRng(x, 1)
        myArr(2, Z) = myRng(x, 2)
        myArr(3, Z) = myRng(1, y + 2)
        myArr(4, Z) = myRng(x, y + 2)
        Z = Z + 1
    Next y
Next x
ThisWorkbook.Sheets("desired").Range("A3:D" & Z + 1) = Application.Transpose(myArr)
End Sub

Open in new window


If the code needs to be more "flexible" can change the code if required.
pivotDesired.xlsm
0
 
RayneAuthor Commented:
Thanks everyone for your help

Teylyn, Please check attached. This is what I got so far.
I don’t understand what to do here?-
"In the Pivot table field pane, drag all the fields from the Column Labels and the Row Labels areas back up into the field list"

Can you explain? I dragged all the three fields out of there, after which I didn’t see anything
pivotSoFar.png
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
See the four panels at the bottom of the field list in the pivot pane? The upper right has the "Column" field in it. The lower left has the "Row" field in it. Click and drag these two items up into the field list, so that the two panes are empty and the only thing left is "Sum of Value" in the lower right hand box.

That will transform the pivot table into a one cell affair with a label. Then double click the number in the one pivot cell.
0
 
SteveConnect With a Mentor Commented:
Cool method Teylyn:

Rayne, all you now do is drag the row and column off the column and row label areas..
So as to just leave the "Sum Of"

Then double click the large number that is left.
This will create the same data as the macro.
Cool.

I am sure that this would be a great topic for an article. ;)
0
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
>> I am sure that this would be a great topic for an article. ;)

John Walkenbach already wrote it up. http://spreadsheetpage.com/index.php/tip/creating_a_database_table_from_a_summary_table/
0
 
SteveCommented:
Ahha... "good old" John,

His is are some of the few books I have in actual book form, and would heartily recommend.
(that and a dictionarry, as I am sure my spelling is getting worse as I get older)

But this is a great example of returning pivot data back to normal form.
Cheers,
Steve.
0
 
RayneAuthor Commented:
Thanks Everyone for chipping in
Teylyn
All Hats off to you :)
Thanks a million
0
 
RayneAuthor Commented:
Here's the follow up question...if anyone is interested :)
0
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.

All Courses

From novice to tech pro — start learning today.