This was taken and improved slightly from Question that has since been deleted
For those who can see deleted posts, it was taken from here: https://
Assuming the format of the data is always Name then P, M and N this formula does the work:
Name
P
M
N
=INDEX($A:$D, MATCH($H$3,$A:$A,0) +LOOKUP($H$4,{"P",1;"M",2;"N",3}), MATCH($H$5,$1:$1,0))