以文本方式查看主题

-  易表在线答疑  (http://egrid2000.com/dvbbs/index.asp)
--  用户社区  (http://egrid2000.com/dvbbs/list.asp?boardid=2)
----  分类汇总函数可不可以只对超过一条相同条件的记录进行汇总?  (http://egrid2000.com/dvbbs/dispbbs.asp?boardid=2&id=7496)

--  作者:zhangxr
--  发布时间:2007/4/21 16:06:00
--  分类汇总函数可不可以只对超过一条相同条件的记录进行汇总?
请教高手:
分类汇总函数可不可以只对超过一条相同条件的记录进行汇总?
如:
料号      数量
A01-001   100
A01-002   120
A01-002    50
A02-001   110
A02-002   150
A02-002    20
A02-002    30


汇总后效果
料号      数量
A01-001    100
A01-002    120
A01-002     50
小计 A01-002  170
A02-001    110
A02-002    150
A02-002     20
A02-002     30
小计 A02-002  200
总计:        580


--  作者:smileboy
--  发布时间:2007/4/21 16:35:00
--  
发文件
--  作者:Eval
--  发布时间:2007/4/21 18:04:00
--  
设1数值型变量:%zsl%

ClearSubtotal() And DelFor(Grid,"料号","=","") And DelFor(Grid,"料号","instr","小计") And DelFor(Grid,"料号","=","总计") And Eval("SetVariable(""%zsl%"","+text(sumfor(Grid,"数量"))+")")And CreateGrid(".","料号",0,"数量",1,"Y",3) And Cleargrid(grids) and CopyRows(grids) And DelRow(grids,1) And Do(220,1) and EvalFor(grid,"料号","IF(if(FindRow(Grids,""料号"",""="",[料号],2)=0,ReplaceFor(Grids,""Y"",-1,""料号"",""="",[料号]),True),[料号],[料号])",0,0,1) And DelFor(grids,"Y","=",-1) And EvalFor(grids,3,"SubtotalFill(Grids,""料号"",""数量"",2)",1,1) And EvalFor(grids,1,"[料号]+""小计""","料号", "<>" ,"总计") And Do(112) and AppendRows(grids) And RemoveGrid(grids)And SetCellText(Grid,Rows,"数量",[%zsl%]) And SortCol(Grid,"料号",1)And EvalFor(Grid,"料号","""小计 ""+Substitute([料号],""小计"","""")","料号", "instr" ,"小计") And MarkRowFor(12910591,0,"料号", "instr" ,"小计")And MarkRowFor(8453888,0,"料号","=","总计")


--  作者:zhangxr
--  发布时间:2007/4/23 8:32:00
--  
谢谢3楼高手,但你的方法我有点看不明白,我用了个变通方法,已经解决了。
1.就是增加一个逻辑列来决定小计行ROW是否被隐藏,
2.再找一列来设操作公式-给逻辑列赋值,
3.重算操作公式所在的列
4.将不要的小计行隐藏。
--  作者:Eval
--  发布时间:2007/4/23 10:26:00
--  
给你个简单点的:

If(cell(Rows,"料号") = "总计",ClearSubtotal(),Subtotal("料号","数量",2) And EvalFor(grid,"料号","If(FindRow(Grid,""料号"",""="",Substitute([料号],""小计 "",""""),2)=0,If(DelRow(Grid,Row),[料号],[料号]),[料号])","料号","instr","小计"))