Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共2 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:交叉统计的“合计”列能否变成“平均”

1楼
wangnovel 发表于:2024/5/7 19:42:00
交叉统计中,勾选“水平方向自动汇总”,能够实现水平方向的汇总,有没有办法实现水平方向的求平均值?
2楼
有点蓝 发表于:2024/5/7 20:17:00
增加一个平均列,生成统计表然后遍历所有行所有列逐个计算,比如示例一:http://www.foxtable.com/webhelp/topics/3285.htm

Dim b As New CrossTableBuilder("统计表1",DataTables("订单"))
b.HGroups.AddDef("
客户"'添加客户列用于水平分组
b.VGroups.AddDef("
产品"'添加产品列用于垂直分组
b.Totals.AddDef("
数量"'添加数量列用于统计
b.Build '
生成统计表
Maintable = Tables("统计表1"'打开生成的统计表
DataTables("统计表1").DataCols.Add("平均", GetType(Double))
for each r as row in Tables("统计表1").rows
dim n as integer = 0
dim sum as double = 0
for each c as col in Tables("统计表1").cols
if c.name <> "客户" then
if r.isnull(c.name) = false then
n += 1
sum += r(c.name)
endif
end if
next
if n>0
r("平均") = sum / n
end if
next
共2 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .01563 s, 2 queries.