working with Nested IF statement in excel

2019-07-14 07:42发布

ID   Height   Phase   Corrected_Height  Final
1    0        A       0                 0
2    1.2      A       1.2               1.2
3    3.9      A       3.9               3.9
4    5.8      A       5.8               5.8
5    4.6      A       NA                7.7
6    7.7      A       7.7               9.3
7    9.3      A       9.3              10.8
..
300  237.5    P       237.5             ..
301  234.7    D       234.7             ..
302  233.3    D       233.3             ..
303  235.1    D       NA                ..
555  1.0      D       1.0   

I have a set of data of similar structure. Calculation of the Phase column was done according to the formula =IF(B2=MAX(B:B);"P";IF(ROW(B2)<MATCH(MAX(B:B);B:B;0);"A";"D"))thanks to @Scott Craner for the solution Naming a behavior in Excel and to calculate the Corrected_Height column I used =IF(C4="A" & B4>B3;B4; IF(C4="D" & B4<B3;B4;"NA"))). However I did not get the required result. The idea is when in "A" phase, should a lower value arise than the previous one it should change to NA and in "D" phase, should a value be higher than the previous one it should again change to NA. Any suggestion what should I change in the formula? And I also want a final column that gives me the values without NA in it. A,P,and D in phase means Ascent,Peak, and Descent.

1条回答
可以哭但决不认输i
2楼-- · 2019-07-14 08:17

The & operator cannot be used to logically and together two conditions in an Excel formula. Instead, use the AND() function:

=IF(AND(C4="A", B4>B3), B4, IF(AND(C4="D", B4<B3), B4, "NA"))
查看更多
登录 后发表回答