Data Transpose

ritrio314

New Member
Joined
Mar 15, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I need help in transposing the data below using Table ID as uniqueID, basically every time the integer in TableID increments, create a new row with the data transposed. Thank you in advance.




TableIDVendorIDQuestionResponse
---->
TableIDVendorIDWhat's your favorite color?Do you reside in California?Client's Gender
1​
5​
What's your favorite color?Green
1​
5​
GreenYesMale
1​
5​
Do you reside in California?Yes
2​
7​
YellowNoFemale
1​
5​
Client's GenderMale
3​
9​
PurpleNoUnknown
2​
7​
What's your favorite color?Yellow
2​
7​
Do you reside in California?No
2​
7​
Client's GenderFemale
3​
9​
What's your favorite color?Purple
3​
9​
Do you reside in California?No
3​
9​
Client's GenderUnkown
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
try this:

Book1
ABCDEFGHIJKL
1TableIDVendorIDQuestionResponse---->TableIDVendorIDWhat's your favorite color?Do you reside in California?Client's Gender
215What's your favorite color?Green15GreenYesMale
315Do you reside in California?Yes27YellowNoFemale
415Client's GenderMale39PurpleNoUnkown
527What's your favorite color?Yellow    
627Do you reside in California?No    
727Client's GenderFemale    
839What's your favorite color?Purple    
939Do you reside in California?No    
1039Client's GenderUnkown
Sheet1
Cell Formulas
RangeFormula
H2:H4H2=UNIQUE(FILTER(A2:A100,""<>A2:A100))
I2:I9I2=IFNA(VLOOKUP(H2,$A$1:$B$99,2,FALSE),"")
J2:J9J2=IFERROR(FILTER($D$2:$D$100,($J$1=$C$2:$C$100)*($H2=$A$2:$A$100)),"")
K2:K9K2=IFERROR(FILTER($D$2:$D$100,($K$1=$C$2:$C$100)*($H2=$A$2:$A$100)),"")
L2:L9L2=IFERROR(FILTER($D$2:$D$100,($L$1=$C$2:$C$100)*($H2=$A$2:$A$100)),"")
Dynamic array formulas.
 
Upvote 1
Another option
Fluff.xlsm
ABCDEFGHIJKL
1TableIDVendorIDQuestionResponse---->TableIDVendorIDWhat's your favorite color?Do you reside in California?Client's Gender
215What's your favorite color?Green15GreenYesMale
315Do you reside in California?Yes27YellowNoFemale
415Client's GenderMale39PurpleNoUnkown
527What's your favorite color?Yellow
627Do you reside in California?No
727Client's GenderFemale
839What's your favorite color?Purple
939Do you reside in California?No
1039Client's GenderUnkown
11
12
13
Master
Cell Formulas
RangeFormula
H2:L4H2=HSTACK(UNIQUE(FILTER(A2:B100,A2:A100<>"")),WRAPROWS(TOCOL(D2:D100,1),3))
Dynamic array formulas.
 
Upvote 0
that works as long as the data is sorted properly (as it is in the example from the OP), but if it's not then will have jumbled results as shown below:

multiple posts solutions.xlsx
ABCDEFGHIJKLMNOPQR
1TableIDVendorIDQuestionResponse---->TableIDVendorIDWhat's your favorite color?Do you reside in California?Client's GenderTableIDVendorIDWhat's your favorite color?Do you reside in California?Client's Gender
215What's your favorite color?Green15GreenYesMale15GreenYesFemale
315Do you reside in California?Yes27YellowNoFemale27NoYellowMale
427Client's GenderFemale39PurpleNoUnkown39PurpleNoUnkown
539Do you reside in California?No    
627What's your favorite color?Yellow    
715Client's GenderMale    
839What's your favorite color?Purple
927Do you reside in California?No    
1039Client's GenderUnkown    
Data Transpose
Cell Formulas
RangeFormula
H2:H4H2=UNIQUE(FILTER(A2:A100,""<>A2:A100))
I2:I7,I9:I10I2=IFNA(VLOOKUP(H2,$A$1:$B$99,2,FALSE),"")
J2:J7,J9:J10J2=IFERROR(FILTER($D$2:$D$100,($J$1=$C$2:$C$100)*($H2=$A$2:$A$100)),"")
K2:K7,K9:K10K2=IFERROR(FILTER($D$2:$D$100,($K$1=$C$2:$C$100)*($H2=$A$2:$A$100)),"")
L2:L7,L9:L10L2=IFERROR(FILTER($D$2:$D$100,($L$1=$C$2:$C$100)*($H2=$A$2:$A$100)),"")
N2:R4N2=HSTACK(UNIQUE(FILTER(A2:B100,A2:A100<>"")),WRAPROWS(TOCOL(D2:D100,1),3))
Dynamic array formulas.
 
Upvote 0
Thank you so much Fluff and ExceLoki,

Both solutions worked until some point because I found out that not every client has the same number of questions. Therefore, this creates a bigger problem because I cannot use a standard header for everyone. The only way could be creating separate batches for each client with their set of questions as their header. Is this possible? Thank you so much.






TableIDVendorIDQuestionResponseTableIDVendorIDWhat's your favorite color?Do you reside in California?Client's Gender
1​
5​
What's your favorite color?Green
1​
5​
GreenYesMale
1​
5​
Do you reside in California?Yes
1​
5​
Client's GenderMale
2​
7​
What's your favorite color?Yellow---------->TableIDVendorIDWhats your favorite color?Do you reside in California?Whats your marital statusClients Gender
2​
7​
Do you reside in California?No
27YellowNoMarrieFemale
2​
7​
Whats your marital statusMarried
2​
7​
Client's GenderFemale
3​
9​
What's your favorite color?PurpleTableIDVendorIDWhat's your favorite color?Do you reside in California?
3​
9​
Do you reside in California?No
3​
9​
PurpleNo
 
Upvote 0
How about
Fluff.xlsm
ABCDEFGHIJK
1TableIDVendorIDQuestionResponseTableIDVendorIDWhat's your favorite color?Do you reside in California?Client's GenderWhats your marital status
215What's your favorite color?Green15GreenYesMale
315Do you reside in California?Yes27YellowNoFemaleMarried
415Client's GenderMale39PurpleSingle
527What's your favorite color?Yellow
627Do you reside in California?No
727Whats your marital statusMarried
827Client's GenderFemale
939What's your favorite color?Purple
1039Whats your marital statusSingle
11
Main
Cell Formulas
RangeFormula
F1:K1F1=HSTACK(A1:B1,TOROW(UNIQUE(FILTER(C2:C100,C2:C100<>""))))
F2:G4F2=UNIQUE(FILTER(A2:B100,A2:A100<>""))
H2:K4H2=IFNA(INDEX(D2:D100,XMATCH(TAKE(F2#,,1)&DROP(F1#,,2),A2:A100&C2:C100,0)),"")
Dynamic array formulas.
 
Upvote 1
Solution
as long as you're good with all the returns being in the same table, ^ or this should work for you.
if you want/need them broken up into separate tables based on table id, then we'd need to rework these solutions.

multiple posts solutions.xlsx
ABCDEFGHIJKLM
1TableIDVendorIDQuestionResponse---->TableIDVendorIDWhat's your favorite color?Do you reside in California?Client's GenderWhats your marital status
215What's your favorite color?Green15GreenYesMale 
315Do you reside in California?Yes27YellowNoFemaleMarried
415Client's GenderMale39Purple  Single
527What's your favorite color?Yellow     
627Do you reside in California?No     
727Whats your marital statusMarried     
827Client's GenderFemale     
939What's your favorite color?Purple     
1039Whats your marital statusSingle     
Data Transpose
Cell Formulas
RangeFormula
J1:M1J1=TOROW(UNIQUE(FILTER(C2:C100,""<>C2:C100)))
H2:H4H2=UNIQUE(FILTER(A2:A100,""<>A2:A100))
I2:I10I2=IFNA(VLOOKUP(H2,$A$1:$B$99,2,FALSE),"")
J2:M10J2=IFERROR(FILTER($D$2:$D$100,(J$1=$C$2:$C$100)*($O2=$A$2:$A$100)),"")
Dynamic array formulas.
 
Upvote 0
How about
Fluff.xlsm
ABCDEFGHIJK
1TableIDVendorIDQuestionResponseTableIDVendorIDWhat's your favorite color?Do you reside in California?Client's GenderWhats your marital status
215What's your favorite color?Green15GreenYesMale
315Do you reside in California?Yes27YellowNoFemaleMarried
415Client's GenderMale39PurpleSingle
527What's your favorite color?Yellow
627Do you reside in California?No
727Whats your marital statusMarried
827Client's GenderFemale
939What's your favorite color?Purple
1039Whats your marital statusSingle
11
Main
Cell Formulas
RangeFormula
F1:K1F1=HSTACK(A1:B1,TOROW(UNIQUE(FILTER(C2:C100,C2:C100<>""))))
F2:G4F2=UNIQUE(FILTER(A2:B100,A2:A100<>""))
H2:K4H2=IFNA(INDEX(D2:D100,XMATCH(TAKE(F2#,,1)&DROP(F1#,,2),A2:A100&C2:C100,0)),"")
Dynamic array formulas.
This works! Thank you so much!!!!!!!
 
Upvote 0
try this:

Book1
ABCDEFGHIJKL
1TableIDVendorIDQuestionResponse---->TableIDVendorIDWhat's your favorite color?Do you reside in California?Client's Gender
215What's your favorite color?Green15GreenYesMale
315Do you reside in California?Yes27YellowNoFemale
415Client's GenderMale39PurpleNoUnkown
527What's your favorite color?Yellow    
627Do you reside in California?No    
727Client's GenderFemale    
839What's your favorite color?Purple    
939Do you reside in California?No    
1039Client's GenderUnkown
Sheet1
Cell Formulas
RangeFormula
H2:H4H2=UNIQUE(FILTER(A2:A100,""<>A2:A100))
I2:I9I2=IFNA(VLOOKUP(H2,$A$1:$B$99,2,FALSE),"")
J2:J9J2=IFERROR(FILTER($D$2:$D$100,($J$1=$C$2:$C$100)*($H2=$A$2:$A$100)),"")
K2:K9K2=IFERROR(FILTER($D$2:$D$100,($K$1=$C$2:$C$100)*($H2=$A$2:$A$100)),"")
L2:L9L2=IFERROR(FILTER($D$2:$D$100,($L$1=$C$2:$C$100)*($H2=$A$2:$A$100)),"")
Dynamic array formulas.
Thank you so much ExceLoki!!!
 
Upvote 0
Gad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top