Transpose and separate data

Tigerexcel

Active Member
Joined
Mar 6, 2020
Messages
493
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Book4
ABCDE
1TITLENAMESubjectGradeScore
2BusinessTomABC1010D72
3BusinessTomABC1020D75
4BusinessTomABC1110C63
5BusinessTomABC1690D71
6BusinessTomABC1500N45
7BusinessTomABC1700P51
8EngineeringJackABC4160C62
9EngineeringJackABC4390D73
10EngineeringJackABC4490D72
11EngineeringJackABC4140C62
12ArtsPeterABC4160C60
13ArtsPeterABC4390P52
14ArtsPeterABC4140N38
15ArtsPeterABC4270N47
16ArtsFredABC6010N4
17ArtsFredABC6020N3
18ArtsFredABC6090N3
19ArtsFredABC6120N3
20BusinessBertABC2020D73
21BusinessBertABC2040N42
22BusinessBertABC2050D73
23BusinessBertABC2080N44
Sheet1


Would like to have the records showing (with each record component in a separate cell):
Business Tom ABC1010 D 72 ABC1020 D 75 ABC1110 C 63 etc,
Engineering Jack ABC4160 C 62 etc,
 
Hi, I'm new to Power Query. I tried to solve this problem and it seems worked well, post for your reference.
Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Index =Table.AddIndexColumn(Table.UnpivotOtherColumns(Source, {"TITLE", "NAME"}, "Attr", "Value"),"Index",1),
    fx=(x)=>
        Text.From(
            List.Count(
                List.PositionOf(Table.SelectRows(Index,each [Index]<=x{4} and [TITLE]=x{0} and [NAME]=x{1})[Attr],x{2},2))),
    DeleteCol = Table.RemoveColumns(Table.AddColumn(Index,"Helper",each _[Attr]&"."&fx(Record.ToList(_))),{"Attr", "Index"}),
    Pivot = Table.Pivot(DeleteCol, List.Distinct(DeleteCol[Helper]), "Helper", "Value")
in
    Pivot
View attachment 19049
Transpose and separate data.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1TITLENAMESubjectGradeScoreTITLENAMESubject.1Grade.1Score.1Subject.2Grade.2Score.2Subject.3Grade.3Score.3Subject.4Grade.4Score.4Subject.5Grade.5Score.5Subject.6Grade.6Score.6
2BusinessTomABC1010D72ArtsFredABC6010N4ABC6020N3ABC6090N3ABC6120N3
3BusinessTomABC1020D75ArtsPeterABC4160C60ABC4390P52ABC4140N38ABC4270N47
4BusinessTomABC1110C63BusinessBertABC2020D73ABC2040N42ABC2050D73ABC2080N44
5BusinessTomABC1690D71BusinessTomABC1010D72ABC1020D75ABC1110C63ABC1690D71ABC1500N45ABC1700P51
6BusinessTomABC1500N45EngineeringJackABC4160C62ABC4390D73ABC4490D72ABC4140C62
7BusinessTomABC1700P51
8EngineeringJackABC4160C62
9EngineeringJackABC4390D73
10EngineeringJackABC4490D72
11EngineeringJackABC4140C62
12ArtsPeterABC4160C60
13ArtsPeterABC4390P52
14ArtsPeterABC4140N38
15ArtsPeterABC4270N47
16ArtsFredABC6010N4
17ArtsFredABC6020N3
18ArtsFredABC6090N3
19ArtsFredABC6120N3
20BusinessBertABC2020D73
21BusinessBertABC2040N42
22BusinessBertABC2050D73
23BusinessBertABC2080N44
Sheet1
Very nice Shaowu, that is very efficient, you've achieved a lot in just a few steps!
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Very nice Shaowu, that is very efficient, you've achieved a lot in just a few steps!
:giggle:thanks for the feedback:giggle: I began to learn Power Query about one month ago and I found it very interesting and enjoyed solving problems with this tool. I just learned another trick using List.Accumulate and I'd like to share to you?

transform consecutive numbers like 1,2,3,4 to 1-4 and 7,8 to 7-8.

1595952097926.png
 
Upvote 0
:giggle:thanks for the feedback:giggle: I began to learn Power Query about one month ago and I found it very interesting and enjoyed solving problems with this tool. I just learned another trick using List.Accumulate and I'd like to share to you?

transform consecutive numbers like 1,2,3,4 to 1-4 and 7,8 to 7-8.

View attachment 19151
Thank you Shao, I've not heard of List.Accumulate until now, it would appear that it's a very versatile function.
 
Upvote 0
:giggle:thanks for the feedback:giggle: I began to learn Power Query about one month ago and I found it very interesting and enjoyed solving problems with this tool. I just learned another trick using List.Accumulate and I'd like to share to you?

transform consecutive numbers like 1,2,3,4 to 1-4 and 7,8 to 7-8.

View attachment 19151


Thanks for Sharing,, While Practicing I got how to do with formula also.

Book1
JKLMNOPQ
151,2,3,8,9,10,15,1611-3,8-10,15-16
162
173
188
199
2010
2115
2216
23
Sheet9
Cell Formulas
RangeFormula
M15:M114M15=IFERROR(TRIM(MID(SUBSTITUTE(J15,",",REPT(" ",LEN(J15))),(ROW(A1:A100)-ROW(A1))*LEN(J15)+1,LEN(J15)))+0,"")
P15P15=TEXTJOIN(",",TRUE,INDEX($M$15:$M$22,AGGREGATE(15,6,UNIQUE((((M15:M22)-INDEX($M$15:$M$22,ROW(A1:A10)+1)=-1)*ROW(A1:A10)=0)*ROW(A1:A10)),{1;2;3})+1)&"-"&INDEX($M$15:$M$22,IFERROR(AGGREGATE(15,6,UNIQUE((((M15:M22)-INDEX($M$15:$M$22,ROW(A1:A10)+1)=-1)*ROW(A1:A10)=0)*ROW(A1:A10)),{2;3;10}),COUNT($M$15:$M$22))))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,774
Messages
6,174,456
Members
452,566
Latest member
Bonnie_bb

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