Crystal Reports 2008中的公式总和的最大值和最小值 [英] Maximum and Minimum values from a summed Formula in Crystal Reports 2008
问题描述
总计公式问题的最大值和最小值
您好,我目前使用从Oracle数据库获取数据的Crystal Reports 2008。我仔细研究了这一点,并且一直无法找到我需要的信息。我有关于从总计2个或更多字段的给定公式获取最大值和最小值的问题。我使用的信息的快照是:
Field1 = dB1.Left_Serious
Field2 = dB1.Left_Dangerous
Field3 = @Tester
Formula = @LeftTot
字段1 + 2是总数测试人员为每个左测试给出的分数。
测试字段1字段2字段3
1 2.0 4.0 J Adams
2 1.0 1.0 J Adams
3 1.0 0.0 S灰色
4 0.0 1.0 S灰色
5 5.0 0.0 D Jones
6 5.0 8.0 D Jones
$ c
获得每个测试者左测试的总计的公式使用Tester分组:
@LeftTot
Sum({dB1.Left_Serious},{@Tester})+ Sum(dB1.Left_Dangerous},{@Tester})
使用上述详细信息,我们得到:
J Adams = 8.0
S Gray = 2.0
D Jones = 18.0
最大因此,imum的数字是18.0,最小值是2.0,所需的差值是16.0。
我的问题是我无法使用Maximum或Minimum命令,因为Crystal 2008会不允许您在总结两个字段的公式上使用最大值之类的汇总函数。我知道你可以在数据库中创建一个新的聚合字段来解决问题,但是我目前没有管理员访问数据库的权限,也无法创建任何新的数据表或字段。
我曾尝试使用以下3个新公式中的代码来滚动球:
@LeftTotGrpHdr
//此公式需要放入组页眉以重置变量
WhilePrintingRecords;
NumberVar LEFTTL:= 0
@LeftTotGrpFtr
//此公式需要放入组页脚才能显示变量
WhilePrintingRecords;
NumberVar LEFTTL
@LeftTotCr
//此公式声明并计算总剩余测试
WhilePrintingRecords;
Global NumberVar LEFTTL:= LEFTTL + {@LeftTot}
然而,当我尝试使用
最多({@ LeftTotCr})
在一个新的公式中,我仍然收到错误消息This field can not be summaded。
是否有另一种方法可以做到这一点?
干杯
Daveyt
解决方法有一个解决方法。
当您总结数值的同时将数值存储在数组中并检索最大值和最小值
// @ LeftTot
共享StringVar数组x;
x:= x + totext(Sum({dB1.Left_Serious},{@Tester})+ Sum(dB1.Left_Dangerous},{@Tester}));
1
现在再创建一个公式 @display
EvaluateAfter(@LeftTotal);
印刷记录;
共享StringVar数组x;
最大值(x);
以最低限度使用最小值
function。
让我知道它是怎么回事。
Maximum and Minimum values from a summed Formula problem
Hello, I am currently using Crystal Reports 2008 which is getting its data from an Oracle database. I have looked into this at length and I have been unable to find the information I need. I have query about getting the Maximum and Minimum values from a given formula which totals 2 or more fields. A snapshot of the information I am using is:
Field1 = dB1.Left_Serious
Field2 = dB1.Left_Dangerous
Field3 = @Tester
Formula = @LeftTot
Fields 1+2 are the total score given by the Tester for each Left Test.
Test Field1 Field2 Field3
1 2.0 4.0 J Adams
2 1.0 1.0 J Adams
3 1.0 0.0 S Grey
4 0.0 1.0 S Grey
5 5.0 0.0 D Jones
6 5.0 8.0 D Jones
The formula to get the Grand Total for each Tester’s Left Test uses a grouping by Tester:
@LeftTot
Sum ({dB1.Left_Serious}, {@Tester}) + Sum (dB1.Left_Dangerous}, {@Tester})
Using the above details we get:
J Adams = 8.0
S Grey = 2.0
D Jones = 18.0
The Maximum figure is therefore 18.0 and the minimum figure is 2.0 and the required difference is 16.0.
The problem I have is I cannot use the Maximum or Minimum commands as Crystal 2008 will not let you use the Summary Functions like Maximum on a formula that sums two fields. I know you could create a new aggregate field in the database which would solve the problem however I currently do not have administrator access to the databases and cannot create any new data tables or fields.
I have tried to get the ball rolling by using the following code in 3 new formulas:
@LeftTotGrpHdr
//This Formula needs to be placed into the Group Header to reset variable
WhilePrintingRecords;
NumberVar LEFTTL:=0
@LeftTotGrpFtr
//This Formula needs to be placed into the Group Footer to display variable
WhilePrintingRecords;
NumberVar LEFTTL
@LeftTotCr
//This Formula declares and works out Total Left Tests
WhilePrintingRecords;
Global NumberVar LEFTTL:=LEFTTL + {@LeftTot}
However when I try to use
Maximum({@LeftTotCr})
in a new formula I still get the error message "This field cannot be summarised."
Is there another way to do this?
Cheers
Daveyt
解决方案 There is a workaround for this.
When you summarize the value at the same time store the values in array and retrive maximum and minimum from the array.
//@LeftTot
Shared StringVar Array x;
x:=x+totext(Sum ({dB1.Left_Serious}, {@Tester}) + Sum (dB1.Left_Dangerous}, {@Tester}));
1
Now create one more formula @display
EvaluateAfter(@LeftTotal);
Whileprintingrecords;
Shared StringVar Array x;
Maximum(x);
In the same way do for minimum using the minimum
function.
Let me know how it goes.
这篇关于Crystal Reports 2008中的公式总和的最大值和最小值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!