Tuesday, September 17, 2013

Finding last occurrence of a label and its value in Spreadsheet


A B C D E F
1
A 11
A 19
2
B 12
B 16
3
C 13
C 15
4
D 14
D 18
5
C 15


6
B 16


7
A 17


8
D 18


9
A 19



Finding a value of label that occurs as last in a large list is always complex one. Spreadsheet's lookup functions will helps up to some level but not completely. Using the following workaround, its possible and the desired value can be populated.

Feed the below values in respective cells and press CTRL+SHIFT+ENTER to run the script.

F1 = INDEX($C$1:$C$9,MAX(ROW($A$1:$A$9)*($B$1:$B$9=$E1)))
F2 = INDEX($C$1:$C$9,MAX(ROW($A$1:$A$9)*($B$1:$B$9=$E2)))
F3 = INDEX($C$1:$C$9,MAX(ROW($A$1:$A$9)*($B$1:$B$9=$E3)))
F4 = INDEX($C$1:$C$9,MAX(ROW($A$1:$A$9)*($B$1:$B$9=$E4)))

Here Column "A" was referred just for row number reference nothing else. Column "A" may have any value or empty.

Note: Labels are A-D and values are numeric values.

No comments:

Post a Comment