以文本方式查看主题

-  易表在线答疑  (http://egrid2000.com/dvbbs/index.asp)
--  用户社区  (http://egrid2000.com/dvbbs/list.asp?boardid=2)
----  [求助]请教一个关于筛选的公式  (http://egrid2000.com/dvbbs/dispbbs.asp?boardid=2&id=1665)

--  作者:swg-1954
--  发布时间:2011/11/15 19:17:00
--  [求助]请教一个关于筛选的公式
见编辑栏内
egd文件下载
--  作者:wjq1072
--  发布时间:2011/11/15 20:57:00
--  
egd文件下载
--  作者:swg-1954
--  发布时间:2011/11/15 22:02:00
--  
谢谢wjq1072总版主。就是如此,真的太神了。
还有些公式没弄明白。Eval("ReplaceFor(GridName,""p"",-1,""用户编号"",""="","""+Substitute(ListFor(GridName,"用户编号","fty",-1),"|",""")  重算、替换...筛选为列表项....没有搞懂。
请wjq1072总版主有时间时讲解可否?再次表示深深的谢意!
--  作者:wjq1072
--  发布时间:2011/11/16 8:17:00
--  
AddCol(GridName,"p",3, False ) And
在当前表增加一逻辑辅助列p:

Eval("ReplaceFor(GridName,""p"",-1,""用户编号"",""="","""+Substitute(ListFor(GridName,"用户编号","fty",-1),"|",""") And ReplaceFor(GridName,""p"",-1,""用户编号"",""="",""")+""")") And
替换p列的值为-1,条件是“fty”为-1的“用户编号”的所有行。
这里使用Eval的主要目的是解决“fty”勾选的不确定性。用了Eval函数“fty”勾选就任意了,使公式具有了通用性。
其中:ListFor(GridName,"用户编号","fty",-1)就是找出"fty"为-1的所有对应“用户编号”。
至于Eval函数的写法,请参考论坛相关贴子学习。

FilterFor("p","=",-1,2) And
筛选p列为-1的行;

ClearGrid("峰谷不平处理表") And
清除"峰谷不平处理表",最后剩一空行;

CopyRows("峰谷不平处理表","p","=",-1) And
将当前表p列等于-1的行拷贝到"峰谷不平处理表";

DelRow("峰谷不平处理表",1) And
删除"峰谷不平处理表"的第一行;

DeleteCol(GridName,"p")
最后删除p辅助列。


--  作者:swg-1954
--  发布时间:2011/11/16 12:44:00
--  
特别的感谢wjq1072总版主耐心细致的讲解和指教,感激之情无以言表,只能谢谢!
把三个公式合在一起:SetLabel("  ","稍等---") And AddCol(Grid,"yy",1, False ) And AddCol(Grid,"fty",3, False ) And EvalFor(Grid,"yy","If(Cell(Row,""示数类型"")=""正有功谷"" And Cell(Row +1,""示数类型"")=""正有功总"" And Cell(Row-1,""示数类型"")=""正有功峰"",Cell(Row+1,""本次示数"")-Cell(Row-1,""本次示数""),"""")") And EvalFor(Grid,"fty","If(Cell(Row,""示数类型"")=""正有功谷"" And Cell(Row+1,""示数类型"")=""正有功总"" And Cell(Row-1,""示数类型"")=""正有功峰"" And [本次示数] <> [yy], - 1,0)") And AddCol(GridName,"p",3, False ) And Eval("ReplaceFor(GridName,""p"",-1,""用户编号"",""="","""+Substitute(ListFor(GridName,"用户编号","fty",-1),"|",""") And ReplaceFor(GridName,""p"",-1,""用户编号"",""="",""")+""")") And FilterFor("p","=",-1,2) And ClearGrid("峰谷不平处理表") And CopyRows("峰谷不平处理表","p","=",-1) And DelRow("峰谷不平处理表",1) And DeleteCol(GridName,"p") And OpenGrid("峰谷不平处理表")  
省去两列,公式经测试可用,还可以优化否?

-=-=-=- 以下内容由 swg-19542011年11月16日 00:48pm 时添加 -=-=-=-
Eval("ReplaceFor(GridName,""p"",-1,""用户编号"",""="","""+Substitute(ListFor(GridName,"用户编号","fty",-1),"|",""") And ReplaceFor(GridName,""p"",-1,""用户编号"",""="",""")+""")")这个公式只能慢慢悟。在表去掉Eval为ReplaceFor(GridName,"p",-1,"用户编号","=","8102438288") And ReplaceFor(GridName,"p",-1,"用户编号","=","8102470896") And ReplaceFor(GridName,"p",-1,"用户编号","=","8102470895") And ReplaceFor(GridName,"p",-1,"用户编号","=","8102470893") And ReplaceFor(GridName,"p",-1,"用户编号","=","8102470891")为什么这样,只能在老师的帮助下去体验。
--  作者:wjq1072
--  发布时间:2011/11/16 14:09:00
--  
ReplaceFor(GridName,"p",-1,"用户编号","=","8102438288") And
ReplaceFor(GridName,"p",-1,"用户编号","=","8102470896") And
ReplaceFor(GridName,"p",-1,"用户编号","=","8102470895") And
ReplaceFor(GridName,"p",-1,"用户编号","=","8102470893") And
ReplaceFor(GridName,"p",-1,"用户编号","=","8102470891")

这个不是很好理解吗!说明你当前勾选的就是这5个用户编号。


--  作者:swg-1954
--  发布时间:2011/11/16 20:50:00
--  
谢谢wjq1072总版主的指教,慢慢体验,慢慢琢磨吧!