带有If语句的Excel可以有两个以上的结果

时间:2018-01-29 22:08:28

标签: excel excel-formula

我正在使用这个公式: IF((AND(H11<> “中”,L11<> “中”), “两者”,IF(AND(H11<> “中”,L11 = “”), “第一”),IF(AND( H11 = “”,L11<> “中”), “第二”))

我有两列,如果两列都填满,那么在第三列中写'Both',如果第一列填充但第二列为空,则标记第三列'First',如果第一列为空,填充第二列然后将第三列标记为“第二列” 我在这做错了什么? 我的错误显示如下: enter image description here

任何帮助将不胜感激。

谢谢!

2 个答案:

答案 0 :(得分:3)

正如我在上面的评论中所提到的,你的括号到处都是。你打开一些并在其他地方的随机地点关闭它们。你真的不得不花时间来完成这样复杂的陈述,并确保你的括号正确排列。

我认为这应该适合你:

IF(AND(H11<>"",L11<>""),"Both",IF(AND(H11<>"",L11=""),"First",IF(AND(H11="",L11<>""),"Second")))

我喜欢使用像Notepad ++这样的程序,当你将鼠标悬停在一个上时会突出显示匹配的括号:

例如,将鼠标悬停在第一个AND()之前的第二个括号上,您将看到结束括号在语句后面是WAY。当然,这是没有意义的,因为声明中的第一个括号必须在它之后发生。

enter image description here

当我使用这样的嵌套括号语句进入一个真正的pickle时,我喜欢用新行和缩进来重写它。它很快就突出了问题:

IF(
    (
        AND(
            H11<>"",
            L11<>""
        ),
        "Both",
        IF(
            AND(
                H11<>"",
                L11=""
            ),
            "First"
        ),
        IF(
            AND(
                H11="",
                L11<>""
            ),
            "Second"
        )
    )

你可以再次看到,有些东西不是它所属的东西,至少有一个开头的括号缺少它的右括号。

答案 1 :(得分:0)

结构应如下所示。原始公式有几个错误,第二个和第三个IF没有valuse for false

Traceback (most recent call last):
  File "C:\python36\lib\site-packages\pdfkit\configuration.py", line 21, in __init__
    with open(self.wkhtmltopdf) as f:
FileNotFoundError: [Errno 2] No such file or directory: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "\\EXODUS\FolderRedirections\jarad.collier\My Documents\root\scripts\Jupyter Notebooks\convert_html_to_pdf.py", line 5, in <module>
    pdfkit.from_file('Two_Proportion_Hypothesis_Testing.html', 'out.pdf')
  File "C:\python36\lib\site-packages\pdfkit\api.py", line 47, in from_file
    configuration=configuration, cover_first=cover_first)
  File "C:\python36\lib\site-packages\pdfkit\pdfkit.py", line 42, in __init__
    self.configuration = (Configuration() if configuration is None
  File "C:\python36\lib\site-packages\pdfkit\configuration.py", line 27, in __init__
    'https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf' % self.wkhtmltopdf)
OSError: No wkhtmltopdf executable found: "b''"
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf