简体   繁体   English

单个单元格中有 3 个输出的 Excel IF 公式

[英]Excel IF formula with 3 outputs in a single cell

I am currently working on a sheet where I'm having an issue.我目前正在处理我遇到问题的工作表。

The problem is that I want 3 different outputs to be shown in a single cell using 3 different conditions.问题是我希望使用 3 个不同的条件在单个单元格中显示 3 个不同的输出。 Attaching an image for reference.附上一张图片供参考。

参考图片

Suppose, a person is getting vaccinated and he has taken both shots so the "Ref" cell will show "Done" one after another and the "Status" will show "Done".假设一个人正在接种疫苗并且他已经接种了两次疫苗,因此“Ref”单元格将一个接一个地显示“Done”,而“Status”将显示“Done”。

Now, there's one guys who hasn't taken any shots yet so the "Ref" cell will show "Incomplete" one after another and the "Status" will show "Incomplete".现在,有一个人还没有拍摄任何照片,所以“Ref”单元格会一个接一个地显示“未完成”,“状态”将显示“未完成”。

But there's a person who has taken his first shot and is awaiting his time for the second shot so the "Ref" cell will show "Complete" and "Incomplete" one after another and here the "Status" should show "Partial".但是有一个人已经完成了他的第一次拍摄并正在等待他的第二次拍摄时间,因此“Ref”单元格将依次显示“Complete”和“Incomplete”,此处“Status”应显示“Partial”。

How can it be done?如何做呢?

You can try following formula:您可以尝试以下公式:

=CHOOSE(COUNTIF(A2:A3,"Done")+1,"Incomplete","Partial","Done")

where we use COUNTIF formula to arrive at text string selection.我们使用 COUNTIF 公式来进行文本字符串选择。

Looks quite easy:看起来很简单:

=IF(AND(A2="Done",A3="Done"),
    "Done",
    IF(OR(A2="Done",A3="Done"),
       "Partial",
       "Incomplete"))

If both A2 and A3 equal "Done", you get "Done".如果 A2 和 A3 都等于“完成”,您将获得“完成”。
If A2 or A3 equal "Done", you get "Partial.如果 A2 或 A3 等于“完成”,您将得到“部分”。
Else you get "Incomplete".否则你会得到“不完整”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM