zepher_ma
zepher_ma

Reputation: 1

Transpose data based on two columns and criteria: Excel

I have data that looks like this:

Group: Class:   Value:
A          1        51
A          2        60
B          1        55
B          2        67
B          3        70
C          1        53
C          3        65

Need the data to look like this:

Group:             1:           2:            3: 
    A             51            60             0
    B             55            67            70
    C             53             0            65

The code I am trying is doing two things wrong: 1. Skipping rows 2. not matching value to class column which causes an issue for Group C since it puts the 65 value into class 2 not and not in class 3 for the final row (row 3 in this example).
=IFERROR(IF(AND($B2=1,COLUMN()<3+MATCH($B2,$B3:$B11000,0)),OFFSET(B2,COLUMN()-3,2-COLUMN()),""),"")

Upvotes: 0

Views: 326

Answers (2)

Dang D. Khanh
Dang D. Khanh

Reputation: 1471

This has worked for me.Hope it helps!

=SUMPRODUCT(($A$2:$A$8=$E2)*($B$2:$B$8=COLUMN(A:A))*$C$2:$C$8)

enter image description here

If the C column format is text, let's try:

=IFERROR(OFFSET($C$2,MATCH(1,INDEX(($A$2:$A$8=$E2)*($B$2:$B$8=COLUMN(A$1)),),0)-1,),"")

enter image description here

Upvotes: 1

basic
basic

Reputation: 11968

I think it's more efficient to use PivotTable for such tasks:

enter image description here

Upvotes: 0

Related Questions