Naming a behavior in Excel

2019-07-10 08:20发布

问题:

I have a dataset on height that looks like below.

Height Phase
0      A
2      A
3      A
4      P
4      P
3      D
2      D
1      D
0      D .

I want to create a second column called Phase as above that tells Ascent, Peak, or Descent at corresponding height. I tried to use the IF function as IF(HeiPh="A",B3>=B2,IF(HeiPh="P",4,"D")) . However i'm not getting the required result. I have a big dataset and there are height that is same for few times i.e. like 0 2 2 3 4 5 5 5 5 6 and so on

回答1:

Try this:

=IF(A2=MAX(A:A),"P",IF(ROW(A2)<MATCH(MAX(A:A),A:A,0),"A","D"))



回答2:

You can do this =IF(MAX($A$4:$A$13)=A4,"P",IFS(A5>=A4,"A",A5<A4,"D"))