简体   繁体   English

在msaccess报告中使用IIF

[英]using IIF in msaccess report

I currently have this formula in my report 我的报告中目前有这个公式

=(Sum([Final]*[Units]))/Sum([Units])) =(萨姆([最后] * [单位]))/总和([单位]))

Final - Mostly Integer but has the NG mixed in the records Units - Integer Re-Exam - Contains Integer 最终-主要是整数,但记录中混合了NG单位-整数重新检查-包含整数

Now, with my current formula, if [Final] encounters the value NG, the report gives an error, I want to determine the if the value of [Final] is NG, [Re-Exam] will be checked if it contains a value else 0 will be added to the Sum[Final] and if [Re-Exam] contains a value, [Re-Exam]*[Units] will be added to Sum[Final] 现在,使用我当前的公式,如果[Final]遇到值NG,则报告给出错误,我想确定[Final]的值是否为NG,将检查[Re-Exam]是否包含值否则,将对Sum [Final]添加0,如果[Re-Exam]包含一个值,则将[Re-Exam] * [Units]添加至Sum [Final]

the final result displays the result in general number format 最终结果以通用数字格式显示结果

I am thinking of using IIF but can't generate the correct formula at the moment and that's what i need to fix 我正在考虑使用IIF,但目前无法生成正确的公式,这就是我需要解决的问题

尝试使用Val为非数字字符串返回0:

=Sum(IIf(Val([Final])=0,Val([Re-Exam]),Val([Final]))*[Units])/Sum([Units])

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

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