简体   繁体   English

在公式中使用运行总计-Crystal Reports

[英]Using running totals in formulas - Crystal reports

I have created a set of running totals looking for specific fields in a database. 我创建了一组运行总计,以查找数据库中的特定字段。 If these fields are located, a subsequent sum is performed to calculate the total for that field. 如果找到了这些字段,则执行后续总和以计算该字段的总数。 eg Field to Summarise - DB.Field.Value-Sum. 例如,要汇总的字段-DB.Field.Value-Sum。 Evaluate - Use a Formula-Field Name ='1' 评估-使用公式字段名称='1'

This sums the totals for this field. 这是该字段的总计。 The issue is that I have many running totals doing this, and what I want to do is add these together to provide a total for all of these. 问题是我有很多运行总计在执行此操作,而我想要做的是将这些总计加起来以提供所有这些总计。 Currently I have a formula that uses each field with a '+' between each. 目前,我有一个公式,该公式使用每个字段,每个字段之间都带有“ +”。 This appeared to work fine, but when tested against a record where some of these fields are blank, the subsequent formula displays nothing. 这似乎工作正常,但是当针对其中某些字段为空白的记录进行测试时,后续公式未显示任何内容。

Any advise on what I should do here/ am doing wrong? 我在这里应该做什么/做错了什么建议吗?

Thanks 谢谢

It sounds like a null record (empty value) is breaking your running total. 听起来像是空记录(空值)打破了您的运行总计。 You have a few options 您有几种选择

  1. Use a formula to check for, and replace a null value with another value (Zero, for example) and then use that formula in your running total calculation 使用公式进行检查,然后将空值替换为另一个值(例如,零),然后在运行总计计算中使用该公式

if isnull({Command.Decimal}) then 0 else {Command.Decimal}

  1. Use a SQL expression to replace null with another value Isnull(Tablename.Columnname,0) - use this in your running total 使用SQL表达式将null替换为另一个值Isnull(Tablename.Columnname,0) -在运行总计中使用此值
  2. On the running total, under "evaluate" select Use a formula and use this formula not(isnull({tablename.columnname})) -- If the record IS null, the running total does not evaluate it. 在运行总计上,在“评估”下选择“使用公式”,然后使用此公式not(isnull({tablename.columnname})) -如果记录为空,则运行总计不会对其进行求值。 It will be ignored by the running total. 它将被运行总计忽略。 在此处输入图片说明

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

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