Select values from cells according to contents of other cells

I have data in several long columns. For each row, in column Z I want to have appear the numbers from columns P,Q,R according to the maximum value in columns A,B,C.

For example for each row, if cell B contains a bigger number than either A or C, then I want the number from cell Q to appear in cell Z. If on the other hand cell C is bigger than either A or B, then I want the number from cell R to be in cell Z. And so on.

How can I do this please?

Thanks.

Hello, @galaxian

You can use formula =INDEX(P1:R1;0;MATCH(MAX(A1:C1);A1:C1;0))

— Edit —

Please note that if there are two (or more) equal largest values in cells A1:C1, then index of the first matched value will be returned.