1

我被困在交叉表报告中,我只需要两列值的总和,然后减去总值我应该怎么做?

如下所示,

                   Product 1    Product2    Product 3    Total
                   ----------------------------------
           Cust 1      4           5           2          11
           Cust 2      5           9           7          19

我想对“产品 1”、“产品 3”的值求和。然后从行总数中减去=> Total LIKE [4+2]-11=>TOtal。并想为每个客户重复这个..

任何人请帮帮我。

4

2 回答 2

1

我不确定何时引入嵌入式摘要,但我很确定您的 Crystal 版本具有此功能。如果不是我提前道歉。我现在只使用这种方法几个月了,起初它很混乱。至少对我来说,但它已经派上用场了......我正在对您的交叉表做出以下假设。根据需要更改名称

  • 行 {yourtable.CustID}
  • {yourtable.product} 列
  • 汇总字段 {yourtable.cost}

  • 在交叉表的左上角,右键单击转到高级计算并选择计算成员

    • 选择新建并输入说明
  • 对于类型:选择列
  • 对于插入评估:选择之后
  • 单击编辑插入值并输入
    CurrentColumnIndex=(GetNumColumns-2)//This will insert a column just before the total column
  • 单击编辑标题公式并在引号中输入您要调用的列
  • 选择值公式中的内容,然后单击编辑值公式和数值
  • 保存并关闭然后退出计算成员专家您的交叉表现在应该有一个新列右键单击值转到计算成员并选择编辑计算公式
  • 输入这个公式

( GridValueAt (CurrentRowIndex,0 , 0) // Product 1 value + GridValueAt (CurrentRowIndex,2 , 0) // Product 2 value ) - GetTotalValueFor "yourtable.product")

注意:天哪,很难在这个网站上发帖!

于 2013-04-15T06:47:28.343 回答
0

想了很久之后,我已经完成了......

首先要明确的是,水晶报表 10 不提供以下功能“CurrentRowIndex”、“GridValueAt”,这就是为什么“CoSpringsGuy”的上述解决方案不适用......

因为我们有两张桌子。1 个客户和第 2 个产品,我们生成交叉表,其中包含 product_sold (Qty) 的汇总字段和 2 个交叉表列“Product.name”和子列产品。类型

现在我们想在 product.packing type =“Pilot” 下对每个客户销售的产品的价值求和,然后从所有产品的总和中减去总和(产品类型“Normal”和“Pilot”)

对于这个问题,首先我们必须在水晶运行时格式化公式并操作汇总字段的“显示字符串”然后我们将编辑总计,即最后一列

第一次编辑在以下代码的帮助下汇总了“显示字符串”

Global CCust As String  to keeping last customer for teli new customer name
Global Ccol As String ' tht is for keeping last  column/product.packing type and teli with new col
Global Rndx as number ' this is for generating index of the row
Global totperx(22) as number ' is to hold the currnt value of cell and adding with previous value 
                              ' and i imagen that number of customers will less then 22 otherwise you can take unlimited array

Whileprintingrecords
if (CCust="") then
   CCust=gridrowcolumnvalue("Table_Cust.Name")
   Ccol=gridrowcolumnvalue("Viw_Prod.Packing")
   Rndx=1
   formula="new"
end if

if CCust<>gridrowcolumnvalue("Viw_Prod.Packing") then
    formula="same"
    Rndx=Rndx+1
else
    formula="Newag"
end if

if Ccol<>gridrowcolumnvalue("Viw_Prod.Packing") then
    Rndx=1
end if

if gridrowcolumnvalue("Viw_Prod.Packing")="Pilot" then
    totperx(Rndx)=totperx(Rndx)+currentfieldvalue
end if

formula=totext(currentfieldvalue,0,"") ' despite of cstr function totext will change 45 to 45 while cstr changes 45 to 45.00
CCust=gridrowcolumnvalue("Table_Cust.Name")
Ccol=gridrowcolumnvalue("Viw_Prod.Packing")

现在我们将编辑总计列的“显示字符串”

Global my as number
Global totperx(22) as number
whileprintingrecords
if my<1 then
my=1
end if
formula=currentfieldvalue-totperx(my)
my=my+1
于 2013-04-20T06:24:50.123 回答