以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  平均数合计行统计  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=186899)

--  作者:散客
--  发布时间:2023/6/7 14:45:00
--  平均数合计行统计
Dim b As New SQLGroupTableBuilder("统计表1", "产值调研数据")
b.Groups.AddDef("日期", DateGroupEnum.Year, "年")
b.Groups.AddDef("日期", "月")
b.Groups.AddDef("xz", "属地")
b.Totals.AddDef("产值月度同比增减额1", AggregateEnum.Max, "月产值增减额_最高值")
b.Totals.AddDef("产值月度同比增减额1", AggregateEnum.Average, "月产值增减额_平均值")
b.Totals.AddDef("产值月度同比增减额1", AggregateEnum.Min, "月产值增减额_最低值")
b.Totals.Adddef("产值月度同比增减额1", "月产值增减额_合计")
b.Totals.AddExp("增减_减少_额度", "iif(产值月度同比增减额1 < 0,产值月度同比增减额1,0)")
b.Totals.AddExp("增减_增加_额度", "iif(产值月度同比增减额1 > 0,产值月度同比增减额1,0)")

b.Totals.AddExp("增减_企业总数", "iif(isnull(产值月度同比增减额1),0,1 )")

b.Totals.AddExp("增减_持平_企业数", "iif(产值月度同比增减额1 = 0,1,0)")
b.Totals.AddExp("增减_减少_企业数", "iif(产值月度同比增减额1 < 0,1,0)")


b.Totals.AddExp("增减_增加_企业数", "iif(产值月度同比增减额1 > 0,1,0)")

b.Decimals = 0
b.VerticalTotal = True


b.Filter = "[日期]=# 2023-04-30 #"
\'b.build()
Tables("查询与统计_table2").DataSource = b.BuildDataSource()

Dim r As Row
For i As Integer = 0 To Tables("查询与统计_table2").Rows.Count(True) - 1
    r = Tables("查询与统计_table2").Rows(i, True)
    If r.IsGroup Then
        r("月产值增减额_平均值") = r("月产值增减额_合计") / r("增减_企业总数")
    End If
Next
\'Tables("查询与统计_table2").DataSource = b.BuildDataSource()

我的这段代码为报错,但为实现修正平均值(合计行)的目的,求高人指点!!!

--  作者:有点蓝
--  发布时间:2023/6/7 14:58:00
--  
……
b.Filter = "[日期]=# 2023-04-30 #"
Tables("查询与统计_table2").DataSource = b.BuildDataSource()

Dim r As Row = Tables("查询与统计_table2").Rows(Tables("查询与统计_table2").Rows.count - 1)
r("月产值增减额_平均值") = r("月产值增减额_合计") / r("增减_企业总数")