以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- 提取不重复值及计数 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=137089)
|
-- 作者:蓝蚂蚁
-- 发布时间:2019/6/27 22:12:00
-- 提取不重复值及计数
此主题相关图片如下:图像 2.jpg
想实现的功能:表是窗口1_Table4(经过筛选的表),提取临标=True,且其月份辅助列不重复的值,同时统计不重复值的个数。
如上面的图片中,想要的结果:201905/1个记录/201906/3个记录
窗口1中一按钮代码如下:
Dim t As Table =e.Form.controls("Table4").Table Dim r As Row=e.Form.controls("Table4").Table.Current Dim ss As new List(of String) Dim str As String If Tables("入库单").DataTable.DataCols.Contains("月份辅助列")=False Then Tables("入库单").DataTable.DataCols.Add("月份辅助列", Gettype(String),6) End If Dim ps As new List(of Integer) Dim Products As List(Of String)= e.Form.controls("Table4").Table.DataTable.GetValues("月份辅助列",iif(t.filter>"", t.filter, "1=1") & " And 临标=true") For j As Integer = 0 To Products.Count-1 ps(j)=t.Compute("count(月份辅助列)",iif(t.filter>"", t.filter, "1=1") & " And 临标=true and 月份辅助列=\'Products(j) \'") ss(j)= Products(j) str &= "/" & ss(j) & "/" & ps(j) & “个记录” str = str.trim("/") Next MessageBox.Show(""& str &"", "提示")
|
-- 作者:有点甜
-- 发布时间:2019/6/27 22:38:00
--
修改
ps(j)=t.Compute("count(月份辅助列)",iif(t.filter>"", t.filter, "1=1") & " And 临标=true and 月份辅助列=\'" & Products(j) & "\'")
|
-- 作者:蓝蚂蚁
-- 发布时间:2019/6/27 23:08:00
--
提示错误:
索引超出范围。必须为非负值并小于集合大小。 参数名: index
|
-- 作者:有点甜
-- 发布时间:2019/6/27 23:18:00
--
Dim t As Table =e.Form.controls("Table4").Table Dim r As Row=e.Form.controls("Table4").Table.Current Dim str As String If Tables("入库单").DataTable.DataCols.Contains("月份辅助列")=False Then Tables("入库单").DataTable.DataCols.Add("月份辅助列", Gettype(String),6) End If Dim ps As new List(of Integer) Dim Products As List(Of String)= e.Form.controls("Table4").Table.DataTable.GetValues("月份辅助列",iif(t.filter>"", t.filter, "1=1") & " And 临标=true") For j As Integer = 0 To Products.Count-1 ps(j)=t.Compute("count(月份辅助列)",iif(t.filter>"", t.filter, "1=1") & " And 临标=true and 月份辅助列=\'" & Products(j) & "\'") str &= "/" & Products(j) & "/" & ps(j) & "个记录" & vbcrlf Next MessageBox.Show(str, "提示")
|
-- 作者:蓝蚂蚁
-- 发布时间:2019/6/27 23:33:00
--
提示同样的错误
|
-- 作者:有点蓝
-- 发布时间:2019/6/28 8:54:00
--
For j As Integer = 0 To Products.Count-1 dim cnt as integer=t.Compute("count(月份辅助列)",iif(t.filter>"", t.filter, "1=1") & " And 临标=true and 月份辅助列=\'" & Products(j) & "\'") ps.add(cnt) str &= "/" & Products(j) & "/" & cnt & "个记录" & vbcrlf Next
|
-- 作者:蓝蚂蚁
-- 发布时间:2019/6/28 9:11:00
--
完美解决 谢谢有点蓝/有点甜大神
|