当总重量为零时,将加权平均值显示为零而不是未定义
我正在尝试取一个字段的加权平均值,我们称其为“X”,只要该字段称其为“Y”,加权平均值不为0,它就可以正常工作。但是,当Y为0时,那么X 的值没有出现在报告中,因为它不应该出现,因为它是一个未定义的值。
我想做的是,如果 Y 为 0,则 X 将 = 0 并在报告中显示 0。
我已经尝试了几种方法来使其发挥作用,但都没有成功。目前我想做的是设置一个显示字符串格式化公式来尝试获取它,以便如果 Y 为 0,则 X 为 0 并显示它,但这需要一个字符串作为最终结果。
stringvar s;
NumberVar x := Weighted Average ( fieldX)
numbervar y := fieldY
if Y = 0 then x = 0;
X;
所以我的问题是如何将 numberVar 转换为 stringVar,或者是否有更好的方法来完成我希望完成的任务?
I am attempting to take the weighted average of a field, lets call it "X", which works fine so long as the field lets call it "Y" that the weighted average is with is not 0. However, when Y is 0 then the value for X does not appear in the report as it shouldn't, since it is an undefined value.
What I would like to do is have it so that if Y is 0, then X will be = to 0 and display 0 in the report.
I've have tried several things to get this to work, however they have not succeded. Currently what I am trying to do is set up a Display String Formating Formula to try and get it so that if Y is 0 then X is 0 and display this, however this requires a string to be the end result.
stringvar s;
NumberVar x := Weighted Average ( fieldX)
numbervar y := fieldY
if Y = 0 then x = 0;
X;
So my question is how do I convert a numberVar into a stringVar, or is there a better method to go about doing what I am hoping to accomplish?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,您根本不需要在这里涉及字符串变量。该代码中有一些语法错误。如果您将编写的公式进行以下小更改,它应该在报告中显示良好
但是,更简单的方法是完全放弃使用变量
It doesn't seem to me that you need to involve stringvars at all here. There are some syntax errors in that code. If you put the formula you have written with the following small changes it should display fine in the report
However, an even easier way would be to forego using variables at all