Converting specific columns to vertical one record

dankar

Board Regular
Joined
Mar 23, 2016
Messages
113
Office Version
  1. 365
Platform
  1. Windows
I have similar to this table with many columns and thousand of rows (patients)

- as you can see each patient have 6 tests(test1 to test6) with different 6 result.
- all other columns have the same result.
- I need to switch the results from vertical to horizontal so I the table can show one record for each patient. like table2

Table 1:

Before:
[TABLE="width: 542"]
<tbody>[TR]
[TD="width: 62, bgcolor: white"]FILE NO
[/TD]
[TD="width: 86, bgcolor: white"]RCVD DATE
[/TD]
[TD="width: 76, bgcolor: white"]COUNTRY
[/TD]
[TD="width: 87, bgcolor: white"]ID_NO
[/TD]
[TD="width: 80, bgcolor: white"]PID_NO
[/TD]
[TD="width: 121, bgcolor: white"]TEST
[/TD]
[TD="width: 104, bgcolor: white"]RESULT
[/TD]
[TD="width: 105, bgcolor: white"]REPORT DATE
[/TD]
[/TR]
[TR]
[TD="bgcolor: white"]1
[/TD]
[TD="bgcolor: white"]5/1/2018
[/TD]
[TD="bgcolor: white"]USA
[/TD]
[TD="bgcolor: white"]1234567890
[/TD]
[TD="bgcolor: white"]ABCDEFGH
[/TD]
[TD="bgcolor: white"]TEST1
[/TD]
[TD="bgcolor: white"]NOT TESTED
[/TD]
[TD="bgcolor: white"]5/25/2018
[/TD]
[/TR]
[TR]
[TD="bgcolor: white"]1
[/TD]
[TD="bgcolor: white"]5/1/2018
[/TD]
[TD="bgcolor: white"]USA
[/TD]
[TD="bgcolor: white"]1234567890
[/TD]
[TD="bgcolor: white"]ABCDEFGH
[/TD]
[TD="bgcolor: white"]TEST2
[/TD]
[TD="bgcolor: white"]NOT TESED
[/TD]
[TD="bgcolor: white"]5/25/2018
[/TD]
[/TR]
[TR]
[TD="bgcolor: white"]1
[/TD]
[TD="bgcolor: white"]5/1/2018
[/TD]
[TD="bgcolor: white"]USA
[/TD]
[TD="bgcolor: white"]1234567890
[/TD]
[TD="bgcolor: white"]ABCDEFGH
[/TD]
[TD="bgcolor: white"]TEST3
[/TD]
[TD="bgcolor: white"]POSITIVE
[/TD]
[TD="bgcolor: white"]5/25/2018
[/TD]
[/TR]
[TR]
[TD="bgcolor: white"]1
[/TD]
[TD="bgcolor: white"]5/1/2018
[/TD]
[TD="bgcolor: white"]USA
[/TD]
[TD="bgcolor: white"]1234567890
[/TD]
[TD="bgcolor: white"]ABCDEFGH
[/TD]
[TD="bgcolor: white"]FINAL RESULT
[/TD]
[TD="bgcolor: white"]POSTTIVE
[/TD]
[TD="bgcolor: white"]5/25/2018
[/TD]
[/TR]
[TR]
[TD="bgcolor: white"]1
[/TD]
[TD="bgcolor: white"]5/1/2018
[/TD]
[TD="bgcolor: white"]USA
[/TD]
[TD="bgcolor: white"]1234567890
[/TD]
[TD="bgcolor: white"]ABCDEFGH
[/TD]
[TD="bgcolor: white"]TEST4
[/TD]
[TD="bgcolor: white"]NOT TESTED
[/TD]
[TD="bgcolor: white"]5/25/2018
[/TD]
[/TR]
[TR]
[TD="bgcolor: white"]1
[/TD]
[TD="bgcolor: white"]5/1/2018
[/TD]
[TD="bgcolor: white"]USA
[/TD]
[TD="bgcolor: white"]1234567890
[/TD]
[TD="bgcolor: white"]ABCDEFGH

[/TD]
[TD="bgcolor: white"]TEST5
[/TD]
[TD="bgcolor: white"]NOT TESTED
[/TD]
[TD="bgcolor: white"]5/25/2018
[/TD]
[/TR]
[TR]
[TD="bgcolor: white"]1
[/TD]
[TD="bgcolor: white"]5/1/2018
[/TD]
[TD="bgcolor: white"]USA
[/TD]
[TD="bgcolor: white"]1234567890
[/TD]
[TD="bgcolor: white"]ABCDEFGH
[/TD]
[TD="bgcolor: white"]TEST6
[/TD]
[TD="bgcolor: white"]PENDING
[/TD]
[TD="bgcolor: white"]5/25/2018
[/TD]
[/TR]
</tbody>[/TABLE]

Table 2

After:
[TABLE="width: 928"]
<tbody>[TR]
[TD="width: 62, bgcolor: white"]FILE NO
[/TD]
[TD="width: 86, bgcolor: white"]RCVD DATE
[/TD]
[TD="width: 76, bgcolor: white"]COUNTRY
[/TD]
[TD="width: 87, bgcolor: white"]ID_NO
[/TD]
[TD="width: 80, bgcolor: white"]PID_NO
[/TD]
[TD="width: 121, bgcolor: white"]TEST1
[/TD]
[TD="width: 104, bgcolor: white"]TEST2
[/TD]
[TD="width: 105, bgcolor: white"]TEST3
[/TD]
[TD="width: 104, bgcolor: white"]TEST4
[/TD]
[TD="width: 104, bgcolor: white"]TEST5
[/TD]
[TD="width: 81, bgcolor: white"]TEST6
[/TD]
[TD="width: 120, bgcolor: white"]FINAL RESULT
[/TD]
[TD="width: 105, bgcolor: white"]REPORT DATE
[/TD]
[/TR]
[TR]
[TD="bgcolor: white"]1
[/TD]
[TD="bgcolor: white"]5/1/2018
[/TD]
[TD="bgcolor: white"]USA
[/TD]
[TD="bgcolor: white"]1234567890
[/TD]
[TD="bgcolor: white"]ABCDEFGH
[/TD]
[TD="bgcolor: white"]NOT TESTED
[/TD]
[TD="bgcolor: white"]NOT TESTED
[/TD]
[TD="bgcolor: white"]POSITIVE
[/TD]
[TD="bgcolor: white"]NOT TESTED
[/TD]
[TD="bgcolor: white"]NOT TESTED
[/TD]
[TD="bgcolor: white"]PENDING
[/TD]
[TD="bgcolor: white"]POSITIVE
[/TD]
[TD="bgcolor: white"]5/25/2018
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Re: convering spicific coulmns to vertical one record

try

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]FILE NO[/td][td=bgcolor:#5B9BD5]RCVD DATE[/td][td=bgcolor:#5B9BD5]COUNTRY[/td][td=bgcolor:#5B9BD5]ID_NO[/td][td=bgcolor:#5B9BD5]PID_NO[/td][td=bgcolor:#5B9BD5]TEST[/td][td=bgcolor:#5B9BD5]RESULT[/td][td=bgcolor:#5B9BD5]REPORT DATE[/td][td][/td][td=bgcolor:#70AD47]FILE NO[/td][td=bgcolor:#70AD47]RCVD DATE[/td][td=bgcolor:#70AD47]COUNTRY[/td][td=bgcolor:#70AD47]ID_NO[/td][td=bgcolor:#70AD47]PID_NO[/td][td=bgcolor:#70AD47]TEST1[/td][td=bgcolor:#70AD47]TEST2[/td][td=bgcolor:#70AD47]TEST3[/td][td=bgcolor:#70AD47]TEST4[/td][td=bgcolor:#70AD47]TEST5[/td][td=bgcolor:#70AD47]TEST6[/td][td=bgcolor:#70AD47]FINALRESULT[/td][td=bgcolor:#70AD47]REPORT DATE[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]
05/01/2018​
[/td][td=bgcolor:#DDEBF7]USA[/td][td=bgcolor:#DDEBF7]
1.23E+09​
[/td][td=bgcolor:#DDEBF7]ABCDEFGH[/td][td=bgcolor:#DDEBF7]TEST1[/td][td=bgcolor:#DDEBF7]NOT TESTED[/td][td=bgcolor:#DDEBF7]
25/05/2018​
[/td][td][/td][td=bgcolor:#E2EFDA]
1​
[/td][td=bgcolor:#E2EFDA]
05/01/2018​
[/td][td=bgcolor:#E2EFDA]USA[/td][td=bgcolor:#E2EFDA]
1234567890​
[/td][td=bgcolor:#E2EFDA]ABCDEFGH[/td][td=bgcolor:#E2EFDA]NOT TESTED[/td][td=bgcolor:#E2EFDA]NOT TESED[/td][td=bgcolor:#E2EFDA]POSITIVE[/td][td=bgcolor:#E2EFDA]NOT TESTED[/td][td=bgcolor:#E2EFDA]NOT TESTED[/td][td=bgcolor:#E2EFDA]PENDING[/td][td=bgcolor:#E2EFDA]POSTTIVE[/td][td=bgcolor:#E2EFDA]
25/05/2018​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
1​
[/td][td]
05/01/2018​
[/td][td]USA[/td][td]
1.23E+09​
[/td][td]ABCDEFGH[/td][td]TEST2[/td][td]NOT TESED[/td][td]
25/05/2018​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]
05/01/2018​
[/td][td=bgcolor:#DDEBF7]USA[/td][td=bgcolor:#DDEBF7]
1.23E+09​
[/td][td=bgcolor:#DDEBF7]ABCDEFGH[/td][td=bgcolor:#DDEBF7]TEST3[/td][td=bgcolor:#DDEBF7]POSITIVE[/td][td=bgcolor:#DDEBF7]
25/05/2018​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
1​
[/td][td]
05/01/2018​
[/td][td]USA[/td][td]
1.23E+09​
[/td][td]ABCDEFGH[/td][td]FINALRESULT[/td][td]POSTTIVE[/td][td]
25/05/2018​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]
05/01/2018​
[/td][td=bgcolor:#DDEBF7]USA[/td][td=bgcolor:#DDEBF7]
1.23E+09​
[/td][td=bgcolor:#DDEBF7]ABCDEFGH[/td][td=bgcolor:#DDEBF7]TEST4[/td][td=bgcolor:#DDEBF7]NOT TESTED[/td][td=bgcolor:#DDEBF7]
25/05/2018​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
1​
[/td][td]
05/01/2018​
[/td][td]USA[/td][td]
1.23E+09​
[/td][td]ABCDEFGH[/td][td]TEST5[/td][td]NOT TESTED[/td][td]
25/05/2018​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"FILE NO", Int64.Type}, {"RCVD DATE", type date}, {"COUNTRY", type text}, {"ID_NO", Int64.Type}, {"PID_NO", type text}, {"TEST", type text}, {"RESULT", type text}, {"REPORT DATE", type date}}),
    Pivot = Table.Pivot(Type, List.Distinct(Type[TEST]), "TEST", "RESULT"),
    Reorder = Table.ReorderColumns(Pivot,{"FILE NO", "RCVD DATE", "COUNTRY", "ID_NO", "PID_NO", "TEST1", "TEST2", "TEST3", "TEST4", "TEST5", "TEST6", "FINALRESULT", "REPORT DATE"})
in
    Reorder[/SIZE]
 
Last edited:
Upvote 0
Re: convering spicific coulmns to vertical one record

try

[TABLE="class: head"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]FILE NO[/COLOR]
[/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]RCVD DATE[/COLOR]
[/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]COUNTRY[/COLOR]
[/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]ID_NO[/COLOR]
[/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]PID_NO[/COLOR]
[/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]TEST[/COLOR]
[/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]RESULT[/COLOR]
[/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]REPORT DATE[/COLOR]
[/TD]
[TD][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]FILE NO[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]RCVD DATE[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]COUNTRY[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]ID_NO[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]PID_NO[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]TEST1[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]TEST2[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]TEST3[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]TEST4[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]TEST5[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]TEST6[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]FINALRESULT[/COLOR]
[/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]REPORT DATE[/COLOR]
[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
1​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
05/01/2018​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]USA
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
1.23E+09​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]ABCDEFGH
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]TEST1
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]NOT TESTED
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
25/05/2018​
[/TD]
[TD][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]
1​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]
05/01/2018​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]USA
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]
1234567890​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]ABCDEFGH
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]NOT TESTED
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]NOT TESED
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]POSITIVE
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]NOT TESTED
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]NOT TESTED
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]PENDING
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]POSTTIVE
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]
25/05/2018​
[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD]
1​
[/TD]
[TD]
05/01/2018​
[/TD]
[TD]USA
[/TD]
[TD]
1.23E+09​
[/TD]
[TD]ABCDEFGH
[/TD]
[TD]TEST2
[/TD]
[TD]NOT TESED
[/TD]
[TD]
25/05/2018​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
1​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
05/01/2018​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]USA
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
1.23E+09​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]ABCDEFGH
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]TEST3
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]POSITIVE
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
25/05/2018​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD]
1​
[/TD]
[TD]
05/01/2018​
[/TD]
[TD]USA
[/TD]
[TD]
1.23E+09​
[/TD]
[TD]ABCDEFGH
[/TD]
[TD]FINALRESULT
[/TD]
[TD]POSTTIVE
[/TD]
[TD]
25/05/2018​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
1​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
05/01/2018​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]USA
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
1.23E+09​
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]ABCDEFGH
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]TEST4
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]NOT TESTED
[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DDEBF7]#DDEBF7[/URL] "]
25/05/2018​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD]
1​
[/TD]
[TD]
05/01/2018​
[/TD]
[TD]USA
[/TD]
[TD]
1.23E+09​
[/TD]
[TD]ABCDEFGH
[/TD]
[TD]TEST5
[/TD]
[TD]NOT TESTED
[/TD]
[TD]
25/05/2018​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"FILE NO", Int64.Type}, {"RCVD DATE", type date}, {"COUNTRY", type text}, {"ID_NO", Int64.Type}, {"PID_NO", type text}, {"TEST", type text}, {"RESULT", type text}, {"REPORT DATE", type date}}),
    Pivot = Table.Pivot(Type, List.Distinct(Type[TEST]), "TEST", "RESULT"),
    Reorder = Table.ReorderColumns(Pivot,{"FILE NO", "RCVD DATE", "COUNTRY", "ID_NO", "PID_NO", "TEST1", "TEST2", "TEST3", "TEST4", "TEST5", "TEST6", "FINALRESULT", "REPORT DATE"})
in
    Reorder[/SIZE]

thank you for your reply and help.

will yo please explain how to apply it.

do I need to type table1 in a specific cell before the table. Thank you again
 
Upvote 0
Re: convering spicific coulmns to vertical one record

You'll need PowerQuery (Get&Transform)

your source data should be a table (Excel Table!)
then from Data tab select From Table and in a new Window (Power Query Editor) find and open Advanced Editor then replace code there with code from the post

btw. don't quote whole post !
 
Last edited:
Upvote 0
thank you and sorry for that!

I went though the steps and I got the following although "'FILE NO" is there:

Expression.Error: The column 'FILE NO' of the table wasn't found.
Details:
FILE NO
 
Upvote 0
The code is based on your example from the first post.
You can see the steps in the code, so just do them for your original data or post a real example of your source data.

Power Query is case sensitive so FILE NO is not the same as File No and check for the spaces before and after the headers

Headers must be exactly the same in the code like in source table
and Table Name must be the same as in the code (and vice versa), eg.
Code:
    Source = Excel.CurrentWorkbook(){[Name="[B][SIZE=3][COLOR="#FF0000"]Table1[/COLOR][/SIZE][/B]"]}[Content],
 
Last edited:
Upvote 0
sorry for the inconvenience.

I fixed the hears, I look silly with this..where shall I insert "Table1" to name the table :

Expression.Error: We couldn't find an Excel table named 'Table1'.
Details:
Table1
 
Upvote 0
select your whole source range then use Ctrl+T (with has headers option checked)
then go to Name Manager (Ctrl+F3) and see the name of this table then use this name in the code

if your source range is a Table then check name of this table and use it in the code
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

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