Fill Column with values from a row with a specific text on the left

Copper Contributor

Hello

 

I have a large dataframe and I want to create a new column with gives me the value of cell on the right side of a cell that contains a specific text.

 

The table below is an example of my table. I want to fill the last column (Caffeine) with the values that are written on the right side of the word "caffeine" anywhere in the row. The problem is that caffeine can be written in various places (here in columns concurrent medication 1 AND 2).  I have tried it with index and math, but I cannot get it to work.

 

does anyone know a solution for this?

PATIENT IDPATIENT STATUSWEIGHTDATE OF TREATMENTPATIENT TREATMENT NUMBERRESTIMULATIONCONCURRENT MEDICATION_1CONCURRENT MEDICATION_1 DOSE (MG)CONCURRENT MEDICATION_2CONCURRENT MEDICATION_2 DOSE (MG)Caffeine
875452 8002.03.22 08:4133NoCaffeine200   
875452 8009.02.22 11:4132NoPropofol20Caffeine200 
1 Reply

@Rdog6 

=INDEX(A2:J2,MATCH("Caffeine",A2:J2,0)+1)

Maybe with this formula which seems to work in my sheet.