在Excel

时间:2017-06-22 16:16:59

标签: excel excel-formula

我有3列: 标签/边界/组合。前2列的值为Correct,Not Correct和Not defined。现在基于前两列的值组合,我想自动为第3列Combo生成一个值。例如,如果我有正确/正确,我将在组合列中看到CC。或者,如果我没有纠正/纠正,我将在组合列中看到NC。这是我使用的公式,但它不起作用。我在列Combo中看到的唯一值是False,我错过了什么吗?

=IF(AND(A2="Correct",B2="Correct"),"CC", 
IF(AND(A2="Correct",B2="Not Correct"),"CN",
IF(AND(A2="Not Correct",B2="Correct"),"NC",
IF(AND(A2="Not Correct",B2="Not Correct"),"NN",
IF(AND(A2="Not Defined",B2="Not Defined"),"MM")))))

谢谢,

3 个答案:

答案 0 :(得分:2)

你还没有说明每种可能的情况。由于您有2列,每列有3个值,因此可以为您提供for (int i=0; i<flat_buffer_list.lenght(); i++){ RealmConfiguration config = new RealmConfiguration.Builder() .name("owner.realm") .build(); Realm realm=Realm.getInstance(config); OwnerList list= flatbuffer.OwnerList.getElementAsRoot(flat_buffer_list.get(i)); for (int i=0; i<list.lenght(); i++){ //create the realm object an perform a realm.insert(object) } realm.close(); } 个不同的组合,您应该将它们嵌套在&#34; IF&#34;声明(如果你想这样做)。

您在问题中包含的公式绝对不能涵盖所有公式,如下图所示:

Cases covered

&#34; FALSE&#34;您看到的价值可能是您的公式未涵盖的标签/边界组合。考虑到所有9个案例,该公式将如下所示:

3 ^ 2 = 9

我强烈反对嵌套&#39; IF&#39;在这种情况下的陈述,因为这可能非常难以维护并且容易出错。我建议你改用这个公式来评估它上面的每个单元格并返回两个单元格结果的串联。

=IF(AND(A2="Correct", B2="Correct"),"CC", 
IF(AND(A2="Correct", B2="Not Correct"),"CN",
IF(AND(A2="Correct", B2="Not Defined"),"CM",
IF(AND(A2="Not Correct", B2="Correct"),"NC",
IF(AND(A2="Not Correct", B2="Not Correct"),"NN",
IF(AND(A2="Not Correct", B2="Not Defined"),"NM",
IF(AND(A2="Not Defined", B2="Correct"),"MC",
IF(AND(A2="Not Defined", B2="Not Correct"),"MN",
IF(AND(A2="Not Defined", B2="Not Defined"),"MM")))))))))

答案 1 :(得分:1)

您应该能够使用几个连续的硬编码查找来简化公式。

=LOOKUP(A2, {"Correct","Not Correct","Not Defined"}, {"C","N","M"})&
 LOOKUP(B2, {"Correct","Not Correct","Not Defined"}, {"C","N","M"})

替代,

=CHAR(CODE(A2)-ISNUMBER(SEARCH("defined", A2)))&
 CHAR(CODE(B2)-ISNUMBER(SEARCH("defined", B2)))

enter image description here

答案 2 :(得分:0)

你所拥有的一切都是好的。如果您在前两列中有一组数据不符合您编码的任何情景,则会看到错误。你没有告诉它当你在A或B中没有定义并且在另一列中加上正确或不正确时该怎么做。

=IF(AND(A2="Correct",B2="Correct"),"CC",
IF(AND(A2="Correct",B2="Not Correct"),"CN",
IF(AND(A2="Not Correct",B2="Correct"),"NC",
IF(AND(A2="Not Correct",B2="Not Correct"),"NN",
IF(AND(A2="Not Defined",B2="Not Defined"),"MM",
IF(AND(A2="Not Defined",B2="Correct"),"MC",
IF(AND(A2="Not Defined",B2="Not Correct"),"MN",
IF(AND(A2="Correct",B2="Not Defined"),"CM",
IF(AND(A2="Not Correct",B2="Not Defined"),"NM",
"not found")))))))))

以上内容足以解决其他问题,而不是&#34; FALSE&#34;会说&#34;没找到&#34;如果A和B中的值组合未被解决。