Transpose 3 rows formula only sometimes works

JeffGrant

Well-known Member
Joined
Apr 7, 2021
Messages
519
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am transposing from 3 rows to in 1 column to 1 row and 3 columns. This formula is give me hit and miss results. I have colour coded the hits and left the misses blank.

Can somebody please correct the formula and maybe explain why it is doing this.

Thanks


Book1
ABCDEFG
1Weights (kg)
2NameWeight (kg)Name123
3Nick Of Time58.00Nick Of Time58.0058.0058.00
4Nick Of Time58.00Forty Niner58.0058.0058.00
5Nick Of Time58.00Gratias Deo0.0056.5056.50
6Forty Niner58.00Dorado58.0055.5055.50
7Forty Niner58.00Joyrize56.0056.0056.00
8Forty Niner58.00Lucie Manette56.0055.5055.50
9Gratias Deo0.00Artienne0.0056.0056.00
10Gratias Deo58.00She's A Sweet Deel0.0056.0056.00
11Gratias Deo56.50Miss Rona56.0056.0056.00
12Dorado58.00Wuhan Warrior0.0056.0056.00
13Dorado55.00Forever Autumn0.0056.0056.00
14Dorado55.50Hootie Da Blowfish0.0057.0057.00
15Joyrize56.00Via Monte0.0057.0057.00
16Joyrize56.00The Lady Is A Vamp55.0055.0055.00
17Joyrize56.00State Of Power54.0054.0054.00
18Lucie Manette56.00Augusta Red54.0054.0054.00
19Lucie Manette54.00Tiny'n'tuff55.0055.0055.00
20Lucie Manette55.50Next Stop The Moon56.0060.5060.50
21Artienne0.00Native Chimes56.0056.0056.00
22Artienne55.00Luke's Choice57.0058.5058.50
23Artienne56.00Conquered Zone52.0055.0055.00
24She's A Sweet Deel0.00Costa Lante52.5054.0054.00
25She's A Sweet Deel0.00Flying Target53.0052.5052.50
26She's A Sweet Deel56.00Miss Zedel56.0056.0056.00
27Miss Rona56.00Power And Passion54.0051.0051.00
28Miss Rona56.00Overthought57.0057.5057.50
29Miss Rona56.00Crossaro58.5058.5058.50
30Wuhan Warrior0.00Aragain59.0054.0054.00
31Wuhan Warrior56.00
32Wuhan Warrior56.00
33Forever Autumn0.00
34Forever Autumn56.00
35Forever Autumn56.00
36Hootie Da Blowfish0.00
37Hootie Da Blowfish0.00
38Hootie Da Blowfish57.00
39Via Monte0.00
40Via Monte0.00
41Via Monte57.00
42The Lady Is A Vamp55.00
43The Lady Is A Vamp55.00
44The Lady Is A Vamp55.00
45State Of Power54.00
46State Of Power54.50
47State Of Power54.00
48Augusta Red54.00
49Augusta Red54.00
50Augusta Red54.00
51Tiny'n'tuff55.00
52Tiny'n'tuff52.00
53Tiny'n'tuff55.00
54Next Stop The Moon56.00
55Next Stop The Moon56.00
56Next Stop The Moon60.50
57Native Chimes56.00
58Native Chimes55.00
59Native Chimes56.00
60Luke's Choice57.00
61Luke's Choice55.00
62Luke's Choice58.50
63Conquered Zone52.00
64Conquered Zone52.50
65Conquered Zone55.00
66Costa Lante52.50
67Costa Lante53.00
68Costa Lante54.00
69Flying Target53.00
70Flying Target53.00
71Flying Target52.50
72Miss Zedel56.00
73Miss Zedel58.50
74Miss Zedel56.00
75Power And Passion54.00
76Power And Passion54.00
77Power And Passion51.00
78Overthought57.00
79Overthought54.50
80Overthought57.50
81Crossaro58.50
82Crossaro55.50
83Crossaro58.50
84Aragain59.00
85Aragain54.00
86Aragain54.00
Sheet1
Cell Formulas
RangeFormula
D3:D30D3=UNIQUE($A3:$A86)
E3:E30E3=IFERROR(VALUE(INDEX($B$3:$B$2000, SMALL(IF($D3=$A$3:$A$2000, ROW($A$3:$A$2000)-MIN(ROW($A$3:$A$2000))+1, ""), $E$2))),0)
F3:F30F3=IFERROR(VALUE(INDEX($B$3:$B$2000, SMALL(IF($D3=$A$2:$A$2000, ROW($A$3:$A$2000)-MIN(ROW($A$3:$A$2000))+1, ""), F$2))),0)
G3:G30G3=IFERROR(VALUE(INDEX($B$3:$B$2000, SMALL(IF($D3=$A$3:$A$2000, ROW($A$3:$A$2000)-MIN(ROW($A$3:$A$2000))+1, ""), G$2))),0)
Dynamic array formulas.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
You're formula in column F is different to the other 2 columns. It has A$2 not A$3
How about
+Fluff 1.xlsm
ABCDEFG
1Weights (kg)
2NameWeight (kg)Name123
3Nick Of Time58Nick Of Time585858
4Nick Of Time58Forty Niner585858
5Nick Of Time58Gratias Deo05856.5
6Forty Niner58Dorado585555.5
7Forty Niner58Joyrize565656
8Forty Niner58Lucie Manette565455.5
9Gratias Deo0Artienne05556
10Gratias Deo58She's A Sweet Deel0056
11Gratias Deo56.5Miss Rona565656
12Dorado58Wuhan Warrior05656
13Dorado55Forever Autumn05656
14Dorado55.5Hootie Da Blowfish0057
15Joyrize56Via Monte0057
16Joyrize56The Lady Is A Vamp555555
17Joyrize56State Of Power5454.554
18Lucie Manette56Augusta Red545454
19Lucie Manette54Tiny'n'tuff555255
20Lucie Manette55.5Next Stop The Moon565660.5
21Artienne0Native Chimes565556
22Artienne55Luke's Choice575558.5
23Artienne56Conquered Zone5252.555
24She's A Sweet Deel0Costa Lante52.55354
25She's A Sweet Deel0Flying Target535352.5
26She's A Sweet Deel56Miss Zedel5658.556
27Miss Rona56Power And Passion545451
28Miss Rona56Overthought5754.557.5
29Miss Rona56Crossaro58.555.558.5
30Wuhan Warrior0Aragain595454
31Wuhan Warrior56
32Wuhan Warrior56
33Forever Autumn0
34Forever Autumn56
35Forever Autumn56
36Hootie Da Blowfish0
37Hootie Da Blowfish0
38Hootie Da Blowfish57
39Via Monte0
40Via Monte0
41Via Monte57
42The Lady Is A Vamp55
43The Lady Is A Vamp55
44The Lady Is A Vamp55
45State Of Power54
46State Of Power54.5
47State Of Power54
48Augusta Red54
49Augusta Red54
50Augusta Red54
51Tiny'n'tuff55
52Tiny'n'tuff52
53Tiny'n'tuff55
54Next Stop The Moon56
55Next Stop The Moon56
56Next Stop The Moon60.5
57Native Chimes56
58Native Chimes55
59Native Chimes56
60Luke's Choice57
61Luke's Choice55
62Luke's Choice58.5
63Conquered Zone52
64Conquered Zone52.5
65Conquered Zone55
66Costa Lante52.5
67Costa Lante53
68Costa Lante54
69Flying Target53
70Flying Target53
71Flying Target52.5
72Miss Zedel56
73Miss Zedel58.5
74Miss Zedel56
75Power And Passion54
76Power And Passion54
77Power And Passion51
78Overthought57
79Overthought54.5
80Overthought57.5
81Crossaro58.5
82Crossaro55.5
83Crossaro58.5
84Aragain59
85Aragain54
86Aragain54
List
Cell Formulas
RangeFormula
D3:D30D3=UNIQUE($A3:$A86)
E3:G30E3=TRANSPOSE(FILTER($B$3:$B$2000,$A$3:$A$2000=D3))
Dynamic array formulas.
 
Upvote 0
Pivot your data in Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Weight (kg)", type number}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Inserted Modulo" = Table.AddColumn(#"Added Index", "Modulo", each Number.Mod([Index], 3), type number),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Modulo",{"Index"}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Removed Columns", {{"Modulo", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Removed Columns", {{"Modulo", type text}}, "en-US")[Modulo]), "Modulo", "Weight (kg)")
in
    #"Pivoted Column"
 
Upvote 0
A HUGE thank you to all.

I have been looking at that for over two hours.

Another case of too close to the trees to see the forest.


AGAIN - many thanks
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Pivot your data in Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Weight (kg)", type number}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Inserted Modulo" = Table.AddColumn(#"Added Index", "Modulo", each Number.Mod([Index], 3), type number),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Modulo",{"Index"}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Removed Columns", {{"Modulo", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Removed Columns", {{"Modulo", type text}}, "en-US")[Modulo]), "Modulo", "Weight (kg)")
in
    #"Pivoted Column"
Thanks Alan. I am only an absolute novice at PQ and really only started to use it in an absolute basic way earlier today :(
 
Upvote 0
Steps I took using the U/I
Bring data into PQ Editor
On Add a column, select Add Index. Select start with 1
Next select Standard from the same tab and then select Modulo
Remove the Index Column
On the transform tab, highlight the modulo column and select Pivot
Select Weight to Pivot and click on Advanced and select Do not Aggregate
Close and Load to your Native Excel.
 
Upvote 0
Hi All,

In a bid to expand my novice knowledge of PQ, (inspired by Alan Sidman - Thanks), I followed Alan's directions and was getting all very excited, until I found a glitch.

The glitch is this......

The aim is to transpose rows into columns - ok
The data set can have groups of either 1, 2 or 3 records each.
Using the Modulo function, the data happily transfers into columns of three - ok.

The issue is that if here is only 1 or 2 records in a group, then the Mod (3) screws up the transpose.

What needs to happen is that each group must have 3 records before the transpose.

Is there a way that PQ can count the records in each group and:
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

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