Foxtable(狐表)用户栏目专家坐堂 → 交叉统计如何自动汇总出平均值?


  共有11181人关注过本帖树形打印复制链接

主题:交叉统计如何自动汇总出平均值?

帅哥哟,离线,有人找我吗?
don
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1812 积分:12999 威望:0 精华:14 注册:2008/10/11 18:07:00
  发帖心情 Post By:2011/9/3 23:43:00 [显示全部帖子]

以下是引用bad在2011-9-3 23:39:00的发言:


图片点击可在新窗口打开查看此主题相关图片如下:afd.jpg
图片点击可在新窗口打开查看

上面的公式复制到代码编辑器,点确定后发生上述错误



这是你纸上谈兵的结果!正确的:


Dim s As String
Dim t As Table = Tables("统计汇总")

Dim g As New CrossTableBuilder("统计汇总", DataTables("绩效计划表"))
g.Caption = "统计汇总"
g.HGroups.AddDef("年度")
g.HGroups.AddDef("季度")
g.VGroups.AddDef("分管领导")
g.Totals.AddDef("权重", "权重")
g.Totals.AddDef("实际得分", "实际得分")
g.Decimals = 2
g.Build()

For Each c As col In t.cols
   If c.name <> "年度" AndAlso c.name <> "季度" Then
      s+ = "," &  c.name
  End If
Next

Dim g1 As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True

g1 = New Subtotalgroup
g1.Aggregate = AggregateEnum.Average
g1.GroupOn = "年度"
g1.TotalOn = s.trim(",")
g1.Caption = "{0}年 平均"
t.SubtotalGroups.Add(g1)

g1 = New Subtotalgroup
g1.Aggregate = AggregateEnum.Average
g1.GroupOn = "*"
g1.TotalOn =s.trim(",")
g.Caption = "总平均"
t.SubtotalGroups.Add(g1)
t.Subtotal()
MainTable = t


 回到顶部