0
votes

I have a sheet filled with blood pressure (BP) data, arranged by month.

I am interested in storing the last three BP values in a range per patient, each of which is assigned a row. Note that there are months which do not have BP readings, so there are blanks in the dataset.

The range for the blood pressures is BB:BL.

I was able to find formulas for the last:

=LOOKUP(2,1/(ISNUMBER(BB3:BL3)),BB3:BL3)

and second-to-last:

=LOOKUP(9.99E+307,BB3:INDEX(BB3:BL3,MATCH(9.99E+307,BB3:BL3)-1))

But I am not able to modify the formula above to find the third-to-last non-blank BP value.

Any advice is appreciated!

2

2 Answers

2
votes

To find the third-to-last non-blank value, try using INDEX+AGGREGATE function

1] For data range placed in vertically

In C2, enter formula :

=INDEX(A1:A100,AGGREGATE(14,6,ROW(A1:A100)/(A1:A100<>""),3))

enter image description here

2] For data range placed in horizontally

In B3, enter formula :

=INDEX(1:1,AGGREGATE(14,6,COLUMN(1:1)/(1:1<>""),3))

enter image description here

2.a] If the data range placed in a specified position, e.g. BB3:BH3

The formula become, in B3 formula : >>

=INDEX(BB3:BH3,AGGREGATE(14,6,COLUMN(BB3:BH3)-COLUMN(BA3)/(BB3:BH3<>""),3))

Remark : the Column number must adjusted to COLUMN(BB3:BH3)-COLUMN(BA3) in become {1,2,3,4,5....}

enter image description here

0
votes

If one has the Dynamic Array Formula Filter then:

=INDEX(FILTER(1:1,1:1<>""),COUNTA(FILTER(1:1,1:1<>""))-2)

enter image description here