In Excel, how to use If function with 3 conditions?

In Excel, how to use If function with 3 conditions?


Here is one data. P-values are summarized for genotypes at difference fields.

Now I’d like to add symbols; *,**,*** and n.s. If p-value is less than 0.05, it will be *, and if p-value is less than 0.01, it will be **, and if p-value is less than 0.001, it will be ***, and if all conditions are not met, it will be n.s.

So, I’ll add this code in D column in the excel, and drag this code to the end.

IF(C11<0.001,"***",IF(C11<0.01,"**",IF(C11<0.05,"*","n.s")))

Now, each symbol matched to each p-value.



Be careful!!

What if we write the code like below?

=IF(C2<0.05,"*",IF(C2<0.01,"**",IF(C2<0.001,"***","n.s")))

It shows liked below. The first command is less than 0.05, and will show *. Even though second command is ‘less than 0.01’, the first command is if it’s less than 0.05, it should show *. Therefore, all values less than 0.05 will show * even though it’s less than 0.01 or 0.001.

Therefore, let’s be careful to write code for IF function.


Leave a Reply

If you include a website address in the comment section, I cannot see your comment as it will be automatically deleted and will not be posted. Please refrain from including website addresses.