多个 excel if 语句产生值 1,2 或 3 [英] multiple excel if statements to produce value 1,2 or 3

查看:23
本文介绍了多个 excel if 语句产生值 1,2 或 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出用于此任务的正确 if 语句:

I am trying to find out the right if statement to use for this task:

if B5 is higher than C5 = 1
if B5 is within 2% higher than C5 = 2
if B5 is lower than C5 = 3

我有第二个语句的公式

=IF(AND(B5>(C5-(C5*2/100)),B5<(C5+(C5*2/100))),"yes","no")

我只是不知道如何将其放入一个语句中,以便在最后出现 3 个数字之一.我遇到的主要问题是,在可以返回的 excel if 语句中只有两个答案

Im just not sure how to put it into one statement to get one of the 3 numbers to come out at the end. main thing im struggling with is that there are only two answers in an excel if statement it can return

推荐答案

只是为了确保我理解正确,当 B5 在 C5 的 2% 以内(大于、等于或小于),公式是否应该返回2"?如果是这样,您可以使用以下公式:

Just to make sure I understand correctly, when B5 is within 2% of C5 (either greater than, equal to, or less than), should the formula return "2"? If so, you can use the following formula:

=IF(ABS(B5-C5)<=C5*0.02,2,IF(B5>C5,1,3))

当 B5 正好比 C5 小 2% 或正好比 C5 大 2% 时,此公式返回2".如果您希望它在这些情况下分别返回3"和1",则可以改用以下内容:

This formula returns "2" when B5 is exactly 2% less than or exactly 2% greater than C5. If you want it to return "3" and "1" in these cases respectively, you can use the following instead:

=IF(ABS(B5-C5)<C5*0.02,2,IF(B5>C5,1,3))

这篇关于多个 excel if 语句产生值 1,2 或 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆