以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 分组统计的占比 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=73797) |
-- 作者:阿福 -- 发布时间:2015/8/26 22:35:00 -- 分组统计的占比 Dim g1 As New SQLGroupTableBuilder("统计表1", "母猪基本信息") g1.C Dim d1 As fxDataSource g1.Groups.AddDef("销售_日期", DateGroupEnum.Year, "日期_年") g1.Groups.AddDef("销售_日期", "日期_月") g1.Totals.AddDef("销售_金额", "销售_母猪") d1 = g1.BuildDataSource() Dim g2 As New SQLGroupTableBuilder("统计表2", "公猪信息") g2.C Dim d2 As fxDataSource g2.Groups.AddDef("销售_日期", DateGroupEnum.Year, "日期_年") g2.Groups.AddDef("销售_日期", "日期_月") g2.Totals.AddDef("销售_金额", "销售_公猪") d2 = g2.BuildDataSource() Dim g3 As New SQLGroupTableBuilder("统计表3", "肉猪信息") g3.C Dim d3 As fxDataSource g3.Groups.AddDef("销售_日期", DateGroupEnum.Year, "日期_年") g3.Groups.AddDef("销售_日期", "日期_月") g3.Totals.AddDef("销售_金额", "销售_肉猪") d3 = g3.BuildDataSource() Dim g4 As New SQLGroupTableBuilder("统计表4", "补贴项目") g4.C Dim d4 As fxDataSource g4.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年") g4.Groups.AddDef("日期", "日期_月") g4.Totals.AddDef("金额", "补贴项目") d4 = g4.BuildDataSource() Dim g5 As New SQLGroupTableBuilder("统计表5", "其他收入") g5.C Dim d5 As fxDataSource g5.Groups.AddDef("日期", DateGroupEnum.Year, "日期_年") g5.Groups.AddDef("日期", "日期_月") g5.Totals.AddDef("金额", "其他收入") d5 = g5.BuildDataSource() Dim nms As String() = {"日期_年","日期_月"} d1.Combine(nms,d2,nms) d1.Combine(nms,d3,nms) d1.Combine(nms,d4,nms) d1.Combine(nms,d5,nms) Tables("收入统计_Table1").DataSource = d1 With DataTables("收入统计_Table1").DataCols .Add("合计",Gettype(Integer), "IsNull([销售_母猪],0) + ISNULL([销售_公猪],0) + ISNULL([销售_肉猪],0) + ISNULL([补贴项目],0) + ISNULL([其他收入],0)") .Add("比例_销售_母猪",Gettype(Double),"IsNull([销售_母猪],0) / IsNull([合计],0)") .Add("比例_销售_公猪",Gettype(Double),"IsNull([销售_公猪],0) / IsNull([合计],0)") .Add("比例_销售_肉猪",Gettype(Double),"IsNull([销售_肉猪],0) / IsNull([合计],0)") .Add("比例_补贴项目",Gettype(Double),"IsNull([补贴项目],0) / IsNull([合计],0)") .Add("比例_其他收入",Gettype(Double),"IsNull([其他收入],0) / IsNull([合计],0)") End With 请教老师,如何把黄色部分的显示结果是以双精度小数显示,但想改成是以Format(0.56,"00.0%")显示,需要怎么改? 还有紫色部分的被除数及时空值也不能为0,该怎么改? |
-- 作者:阿福 -- 发布时间:2015/8/26 22:44:00 -- 列设置 数字格式: Dim s As String() = {"比例_母猪","比例_公猪","比例_肉猪","比例_补贴项目","比例_其他收入"} For i As Integer = 0 To s.Length - 1 DataTables("收入统计_Table1").DataCols(s(i)).SetFormat("00.0%") Next
|
-- 作者:大红袍 -- 发布时间:2015/8/26 22:44:00 -- 设置列的显示格式
http://www.foxtable.com/help/topics/1659.htm
不显示0值,
IIF(IsNull([其他收入],0) = 0, null, IsNull([其他收入],0) / IsNull([合计],0)) |
-- 作者:阿福 -- 发布时间:2015/8/26 22:52:00 -- 谢谢大红袍老师! |