您需要創建兩個公式領域內的最高值第一個用於變量初始化,第二個用於大於其他值的條件。
1:創建第一個公式字段並記下以下代碼。將該公式字段的名稱輸入Initialization
。
WhilePrintingRecords;
numbervar dMax := 0;
然後將該公式字段放置在報表頭部分中。
2:現在,創建另一個公式字段並記下該公式字段中的以下代碼。
WhilePrintingRecords;
//dont initialize the 0 in this variable we have already initialized in 1st formula field
numbervar dMax;
//Following condition will check that current sum of that field is greater than
//values stored dMax variable. If the condition is satisfied then value will be initialized
//In dMax variable.
if (IsNull(Sum({TableName.FieldName}, {TableName.GroupField})) = False AND
Sum({TableName.FieldName}, {TableName.GroupField}) > dMax)
dMax:=Sum({TableName.FieldName}, {TableName.GroupField});
dMax;
現在,將此公式字段放在計算彙總值的位置。例如在組頁腳中。
UPDATE:
如果要找出最大值withing四組總。然後在公式字段中寫下以下代碼並將其放在組頁腳中。
WhilePrintingRecords;
numbervar dMax1:=0;
if (Sum ({@Total Contracted Value}, {JCM_MASTER__COST_CODE.Cost_Code})) > (Sum ({@Current Budget}, {JCM_MASTER__COST_CODE.Cost_Code}))
dMax1:=Sum ({@Total Contracted Value}, {JCM_MASTER__COST_CODE.Cost_Code});
else
dMax1:=Sum ({@Current Budget}, {JCM_MASTER__COST_CODE.Cost_Code});
numbervar dMax2:=0;
if (Sum ({@Costs to Date}, {JCM_MASTER__COST_CODE.Cost_Code})) > (Sum ({@Projected Final PM Input}, {JCM_MASTER__COST_CODE.Cost_Code}))
dMax2:=Sum ({@Costs to Date}, {JCM_MASTER__COST_CODE.Cost_Code});
else
dMax2:=Sum ({@Projected Final PM Input}, {JCM_MASTER__COST_CODE.Cost_Code});
if (dMax1 < dMax2)
dMax1 := dMax2;
dMax1;
Hello Sarah。我不完全知道,但我認爲你應該創建公式領域,你可以寫,以檢查哪個值比以前更大。 – Shell 2014-11-07 03:15:05
@Sarah我編輯你的問題添加您的編輯...所以這個問題將更有意義 – Siva 2014-11-08 07:22:53