以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [推荐] 统计 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=186651) |
||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:leoli -- 发布时间:2023/5/17 16:42:00 -- [推荐] 统计 老师,以下黄色标注的,如何统计,谢谢。
|
||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点蓝 -- 发布时间:2023/5/17 16:54:00 -- 如果是分组统计,分别使用【计数】和【求和】即可 如果是在同一个表统计,可以使用compute:http://www.foxtable.com/webhelp/topics/0393.htm
|
||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:leoli -- 发布时间:2023/5/17 18:47:00 -- 老师,如下还是很难的,要达到图二的结果,还请指导一下,谢谢! Dim dt As DataTable = DataTables("表C") Dim C As List(Of String) C = dt.GetValues("月份") For Each Customer As String In C dt("总数量") = dt.Compute("Sum(总数量)","[月份] = \'" & C & "\'") Next |
||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点蓝 -- 发布时间:2023/5/18 8:32:00 -- Dim dt As DataTable = DataTables("表C") Dim C As List(Of String()) C = dt.GetValues("月份|产品") dim dr as datarow For Each Customer As String() In C dr = dt.find("[月份] = \'" & C(0) & "\' and 产品=\'" & c(1) & "\'") dr("总数量") = dt.Compute("Sum(总数量)","[月份] = \'" & C(0) & "\' and 产品=\'" & c(1) & "\'") Next |
||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:leoli -- 发布时间:2023/5/18 20:16:00 -- 老师显示出错了,如下 |
||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点蓝 -- 发布时间:2023/5/18 20:45:00 -- dr = dt.find("[月份] = \'" & Customer (0) & "\' and 产品=\'" & Customer (1) & "\'") |
||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:leoli -- 发布时间:2023/5/20 12:24:00 -- Dim dt As DataTable = DataTables("表C") Dim C As List(Of String()) C = dt.GetValues("月份|产品") Dim dr As DataRow For Each Customer As String() In C dr = dt.find("[月份] = \'" & Customer (0) & "\' and 产品=\'" & Customer (1) & "\'") dr("总数量") = dt.Compute("Sum(总数量)","[月份] = \'" & Customer(0) & "\' and 产品=\'" & Customer(1) & "\'") Next 要达成如下的结果: |
||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点蓝 -- 发布时间:2023/5/20 14:14:00 -- C = dt.GetValues("月份|产品","产品 is not null") |
||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:leoli -- 发布时间:2023/5/21 13:19:00 -- 改这样,啥都没反应 Dim dt As DataTable = DataTables("表C") Dim C As List(Of String()) C = dt.GetValues("月份|产品","产品 is not null") Dim dr As DataRow For Each Customer As String() In C dr = dt.find("[月份] = \'" & Customer (0) & "\' and 产品=\'" & Customer (1) & "\'") dr("总数量") = dt.Compute("Sum(总数量)","[月份] = \'" & Customer(0) & "\' and 产品=\'" & Customer(1) & "\'") Next |
||||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点蓝 -- 发布时间:2023/5/21 20:42:00 -- 如果是副本,看看:http://www.foxtable.com/webhelp/topics/1906.htm |