I have a massive dataset in excel. I would like to rearrange the rows and columns.
Here's a snippet of the data, what it looks like and what I'd like it to look like under.
Area, Channel, Unit, Year1, Year2, Year3, Year4
bel, dc, share, 25, 36, 56, 45
bel, dc, avm, 23, 45, 65, 47,
bel, dc, ats, 45, 2, 3, 4,
bel, tl, share, 25, 36, 56, 45
bel, tl, avm, 23, 45, 65, 47,
bel, tl, ats, 45, 2, 3, 4,
I'd like to switch Unit and the Years (Year1, Year2, Year3, Year4). To look like this
Area, Chennel, Year, Share, avm, ats
bel, dc, Year1, 25, 23, 45
bel, dc, Year2, 36, 45, 2
bel, dc, Year3, 56, 65, 3
bel, dc, Year4, 45, 47, 4
bel, tl, Year1, 25, 23, 45
bel, tl, Year2, 36, 45, 2
bel, tl, Year3, 56, 65, 3
bel, tl, Year4, 45, 47, 4
Is there a way to achieve this?
There are lots of ways to do this sort of thing - I usually use index-match.
I do this sort of thing with index-match.
=INDEX($D$2:$G$4,MATCH(D$7,$C$2:$C$4,0),MATCH($C8,$D$1:$G$1,0))
First I build the spot where I am going to transpose the data:
Then I put in the proper formula:
Here's how it works:
In this usage
Index
takes three arguments: A range of numbers, the row I want to grab from and the column I want to grab from.The range never changes, so I lock that in with dollar signs (hitting f4
INDEX( $D$2:$G$4
The next argument is the row I want to grab from. I use
match
to find it.Match(
takes three arguments also: the value I want to find, the range I am going to find it in, and a0
to let excel know that my range is not in order, and it needs to find an exact match.So my index row is
MATCH(D$7,$C$2:$C$4,0)
: Find"Year1"
in the range$D$1 -> $G$1
. I used the dollar signs here to lock in rows and column so I can copy the formula to the whole table, and only the parts that need to change will.