水晶报表,按条件小计,合计

LH58 2008-05-16 10:47:40

怎么通过公式字段或其它办法得到图中的小计??
...全文
217 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
LH58 2008-05-22
  • 打赏
  • 举报
回复
还有一个问题,怎么让A的字段的内容只显示一次而且显示在最中间呢??

LH58 2008-05-22
  • 打赏
  • 举报
回复
谢谢阿泰
LH58 2008-05-19
  • 打赏
  • 举报
回复
为空判断是很简单的,关键是无重复比较麻烦。

目前已经解决,不过还是有BUG,希望有更好的解决方案。

把我的方案贴出来,大家指点一下:

在页眉中声明全局变量:小计,和总计
WhilePrintingRecords;
Global numbervar tot := 0;
Global numbervar hjamt := 0
在详细资料中用公式字段写条件统计,去空,去重复,就是这里有BUG
WhilePrintingRecords;
if Trim ({GJRPT02.FLAGTSRF})<>""
then Global numbervar tot := tot + {GJRPT02.SWAMNT};
global numbervar hjamt:=hjamt+tot;
if Trim(Previous({GJRPT02.FLAGTSRF}))={GJRPT02.FLAGTSRF} then
tot := tot - {GJRPT02.SWAMNT};
tot;
在组页脚中清空,因为是每组小计
EvaluateAfter ({@xj});
Global numbervar tot :=0;
阿泰 2008-05-19
  • 打赏
  • 举报
回复
补充说明

使用了 A,D,E三个字段分别对应图中的ADE
m变量是为了监视执行进哪个环节了,非必须。

需对数据项目D进行排序~~
阿泰 2008-05-19
  • 打赏
  • 举报
回复
仅用一个公式,防止在详细资料节和组页脚,详细资料节上的公式抑制显示
好像写得很复杂,呵呵。可能也存在问题。


WhileprintingRecords
global t as double '统计值
dim thisField as string '当前字段
global m as string '监视步骤
global z as double '控制最后一条

'判断组切换,重置变量
if {Test001.A} <> PreviousValue ({Test001.A}) then t=0

thisField=iif(isnull({Test001.D}),"",{Test001.D})

if onfirstrecord and thisField<>"" then

if NextIsNull ({Test001.D}) or Nextvalue ({Test001.D})="" then
t=t+{Test001.E}
else
if thisField<>nextvalue({Test001.D}) then
t=t+{Test001.E}
end if
end if

m=m & "111"
end if
if onlastrecord and thisField<>"" and z=0 then
z=z+1
if PreviousIsNull ({Test001.D}) or Previousvalue ({Test001.D})="" then
t=t+{Test001.E}
else
if thisField<>PreviousValue({Test001.D}) then
t=t+{Test001.E}
end if
end if
'formula=t
m=m & "222"
end if
'如果不是第一条也不是最后一条
if not onlastrecord and not onfirstrecord and thisField<>"" then
'if not onlastrecord and thisField<>"" then
'判断前一条是否为空
'如果为空
if PreviousIsNull ({Test001.D}) or Previousvalue ({Test001.D})="" then
t=t+{Test001.E}
m=m & "333"
'如果前一条不为空
else
'判断本条和前一条是否一样
'如果不一样,
if thisField<>PreviousValue({Test001.D}) then
'继续判断本条跟下一条是否一样,如果不一样,则符合条件
'if thisField<>nextvalue({Test001.D}) then
t=t+{Test001.E}
'end if
end if
m=m & "444"
end if
end if

'formula= cstr(t) & m
formula= t


fanfan2436 2008-05-16
  • 打赏
  • 举报
回复
先写一个公式, eee if d is null or d ='' then 0 else e的值。
再写一个公式,对公式字段eee进行统计就ok了。
LH58 2008-05-16
  • 打赏
  • 举报
回复
再发一次


怎么通过公式字段或其它办法得到图中的小计??
sharon_xxj 2008-05-16
  • 打赏
  • 举报
回复
看不到图

4,816

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧