以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 怎样篡改,有多个分组的,分组行数据 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=187037) |
||||
-- 作者:淡月斜阳 -- 发布时间:2023/6/16 15:12:00 -- 怎样篡改,有多个分组的,分组行数据 如图所示,有三级分组 性别,类型,组号, 数据结构为:性别(){ 多个类型 {多个组号 需要篡改,每一级的 汇总结果 求平均值,最大值,最小值,和标准方差 如性别的汇总行 ,求,所有sex=r("sex") 类型,sex= r("sex") and type=r("type") 组,sex= r("sex") and type=r("type") and gorup_num=r("group_num") 问题是:在类型的分组行上,找不到 性别
|
||||
-- 作者:淡月斜阳 -- 发布时间:2023/6/16 15:12:00 -- Dim tb As Table = Forms("bweight").Controls("TbS").Table Dim g As SubtotalGroup tb.SubtotalGroups.Clear g = New SubtotalGroup g.GroupOn = "group_num" g.Aggregate = AggregateEnum.Average g.Caption = "{0}" g.TotalOn = "weight" tb.SubtotalGroups.Add(g) g = New SubtotalGroup g.GroupOn = "type" g.Aggregate = AggregateEnum.Average g.TotalOn = "weight" g.Caption = "{0}:" tb.SubtotalGroups.Add(g) g = New SubtotalGroup g.GroupOn = "sex" g.Aggregate = AggregateEnum.Average g.Caption = "{0}" g.TotalOn = "weight" tb.SubtotalGroups.Add(g) tb.Subtotal \'\'篡改汇总数据 \'Dim r As Row \'For i As Integer = 0 To tb.Rows.Count(True) - 1 \' r = tb.Rows(i, True) \' If r.IsGroup Then \'如果是分组行 \' Dim f As String = "" \' Dim v As String = "" \' Select Case r.Level \' Case 0 \' f = "sex=\'" & r("sex") & "\'" & ";" \' v = "称重只数:" & tb.Compute("count(weight)", f) & ";" \' v &= "平均体重:" & tb.Compute("Avg(weight)", f) & ";" \' r("sex") = r("sex") & "鸡-" & v \' Case 1 \' Case 2 \' End Select \' End If \'Next
|
||||
-- 作者:有点蓝 -- 发布时间:2023/6/16 15:24:00 -- 看不到具体数据无法回答,请展开所有明细,重新截图看看 |
||||
-- 作者:淡月斜阳 -- 发布时间:2023/6/16 15:29:00 -- 此主题相关图片如下:aa.png |
||||
-- 作者:有点蓝 -- 发布时间:2023/6/16 15:31:00 -- 把汇总行也截图出来呀,如果数据多,还是发个实例吧 |
||||
-- 作者:淡月斜阳 -- 发布时间:2023/6/16 15:32:00 -- 此主题相关图片如下:aa.png |
||||
-- 作者:淡月斜阳 -- 发布时间:2023/6/16 15:33:00 -- 目前,只会做到一个分组 此主题相关图片如下:bb.png |
||||
-- 作者:有点蓝 -- 发布时间:2023/6/16 15:40:00 -- 还是把表数据导出发上来看看吧 |
||||
-- 作者:淡月斜阳 -- 发布时间:2023/6/16 15:42:00 --
|
||||
-- 作者:有点蓝 -- 发布时间:2023/6/16 15:56:00 --
Dim r As Row For i As Integer = 0 To tb.Rows.Count(True) - 1 r = tb.Rows(i, True) If r.IsGroup Then \'如果是分组行 Dim f As String = "" Dim v As String = "" Select Case r.Level Case 0 f = "sex=\'" & r("sex") & "\'" v = "称重只数:" & tb.Compute("count(weight)", f) & ";" v &= "平均体重:" & tb.Compute("Avg(weight)", f) & ";" r("sex") = r("sex") & "鸡-" & v Case 1 f = "sex=\'" & tb.Rows(i + 1, True)("sex") & "\' and type=\'" & r("sex").Trim(":") & "\'" \' Output.Show(f) v = "称重只数:" & tb.Compute("count(weight)", f) & ";" v &= "平均体重:" & tb.Compute("Avg(weight)", f) & ";" r("sex") = r("sex") & "鸡-" & v Case 2 End Select End If Next |