Google电子表格公式中的多个嵌套if块 [英] Multiple nested if blocks in google spreadsheets formulas

查看:107
本文介绍了Google电子表格公式中的多个嵌套if块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写类似此伪代码的嵌套if语句:

Im trying to write a nested if statement like this pseudo code :

=IF(h4=1, "CORRECT", IF(h4=2, "CORRECT"), IF(h4=3, "CORRECT"), IF(h4=4, "CORRECT")) 

但是我得到以下错误,如果我写出代码并每次添加一个if语句. IE.仅从第一个if块开始,然后每次添加更多测试,当我添加第三条语句时,它会中断.

But im getting the following error, if i write out the code about and add an if statement each time. ie. start with only the first if block and then add more testing each time, it breaks when i add the third statement.

IF的参数数量错误.预期介于2到3个参数之间, 但收到了4个论点.

Wrong number of arguments to IF. Expected between 2 and 3 arguments, but received 4 arguments.

在Google电子表格中是否有更好的嵌套嵌套方法?

Is there a better way to nest if blocks in google spreadsheets ?

我已在此处制作了有关该问题的Google电子表格: https://docs.google.com/spreadsheets/d/1MBOmaTNI5C_spSVudCQPeanHtoFr36kglg9BXUeAZxU/edit#gid=0

Ive made a google spreadsheet of the issue here : https://docs.google.com/spreadsheets/d/1MBOmaTNI5C_spSVudCQPeanHtoFr36kglg9BXUeAZxU/edit#gid=0

(以上代码仅是嵌套IF块的示例,并非我试图解决的实际问题)

(the above code is only an example of nesting IF blocks, not the actual issue im trying to solve)

推荐答案

错误实际上只是一个简单的语法问题-括号的位置-这是正确的:

The error was actually just a simple syntax issue - the placement of your parentheses - here is the correct:

=IF(H4=1, "CORRECT", IF(H4=2, "CORRECT", IF(H4=3, "CORRECT")))

我也将其固定在您的电子表格上.

I also fixed it on your spreadsheet.

每个if语句本质上都必须包含3个部分,因此if(this,then this,else this)因此,在嵌套时,公式的else这部分是下一个条件..

Every if statement must have 3 parts essentially, so if(this, then this, else this) so when nesting, the else this part of the formula is the next condition..

=IF(h4=1, "CORRECT", IF(h4=2, "CORRECT", IF(h4=3, "CORRECT", IF(h4=4, "CORRECT")))) 

这篇关于Google电子表格公式中的多个嵌套if块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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