Ms access 计算字段的嵌套IIf语句
我在Access表中有这个公式Ms access 计算字段的嵌套IIf语句,ms-access,if-statement,ms-access-2010,Ms Access,If Statement,Ms Access 2010,我在Access表中有这个公式 iif([selling_unit_height]>[selling_unit_length],[selling_unit_height],[selling_unit_length], iif([selling_unit_height]>[selling_unit_width],[selling_unit_height],[selling_unit_width], iif([selling_unit_length]>[selling_unit_w
iif([selling_unit_height]>[selling_unit_length],[selling_unit_height],[selling_unit_length],
iif([selling_unit_height]>[selling_unit_width],[selling_unit_height],[selling_unit_width],
iif([selling_unit_length]>[selling_unit_width],[selling_unit_length],[selling_unit_width])))
在Access中不能执行类似的操作吗?我有三个数字,我想得到三个数字中最大的一个。它说的论点数目不对。如果我不能这样做,那么我需要其他方法的帮助。签出此资源,或尝试搜索“ms access iif”
可以嵌套“Iif”,但语法错误
iif(
[selling_unit_height]>[selling_unit_length], # Condition
[selling_unit_height], # true response
iif( # false response, a new iif
[selling_unit_height]>[selling_unit_width], # condition
[selling_unit_height], # true response
iif( # false response, a new iff
[selling_unit_length]>[selling_unit_width],# condition
[selling_unit_length], # true response
[selling_unit_width] # final false response
)
)
)
我没有真正考虑您所追求的逻辑,只是强调了语法错误。我认为您需要一个公式,可以用作数据类型为计算字段的表达式属性。(这意味着您的数据库是ACCDB类型,并且您的访问版本>=2010。) 我用它作为一个名为maximum的字段的表达式
IIf([h]>=[l]和[h]>=[w],[h],IIf([l]>=[h]和[l]>=[w],[l],IIf([w]>=[h]和[w]>=[l],[w],Null)))
它从这3个字段(h
、l
和w
)中检索最大值,如果其中任何字段包含Null,则检索Null
下面是表格的屏幕截图和示例数据
我的身高=17,长=1,宽=23。这些数字中最大的将是。现在,用你刚刚输入的公式,它拉高=17,这不是最大的数字。然后改变你的真实反应,检查剩下的选择是否比另一个iif更大。出于兴趣,您的数据库表用于什么?也许电子表格更好。我正在为我的公司使用它,但我不能在电子表格中使用它。你是什么意思?改变真实响应,检查其他iif是否更大?哪个是正确的回答?我想如果高度>长度和高度>宽度,那么我可以这样做,如果高度>宽度,那么高度其他宽度如果长度>宽度,那么长度这是数据类型为“计算”的字段的公式?我已将其设置为“计算”