Foxtable(狐表)用户栏目专家坐堂 → 统计学习


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

主题:统计学习

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/11 10:25:00 [显示全部帖子]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:统计.table


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/11 20:25:00 [显示全部帖子]

Dim d1 As Date = e.Form.Controls("DateTimePicker5").Value
If d1 = Nothing Then d1 = Date.Today
Dim filter1 As String = ""
If e.Form.Controls("RadioButton1").Checked Then
    filter1 = "订单日期 = #" & d1 & "#"
ElseIf e.Form.Controls("RadioButton2").Checked Then
    Dim w As Integer = d1.DayOfWeek '算出今天是星期几
    Dim dt1 As Date = d1.AddDays(0 - w) '获取本周的第一天 ,星期一到星期天
    Dim dt2 As Date = d1.AddDays(6 - w) '获取本周的最后一天
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton3").Checked Then
    Dim y As Integer = d1.Year
    Dim m As Integer = d1.Month
    Dim dt1 As New Date(y, m, 1)
    Dim dt2 As New Date(y, m, Date.DaysInMonth(y, m)) '获取本月的最后一天
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton4").Checked Then
    Dim y As Integer = d1.Year
    Dim q As Integer = (d1.Month - 1) \ 3 + 1 '计算现在是第几个季度
    Dim dt1 As New Date(y, 3 * (q - 1) + 1, 1) '获取本季度的第一天
    Dim dt2 As New Date(y, 3 * q, Date.DaysInMonth(y,3 * q)) '获取本季度的最后一天
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton5").Checked Then
    Dim y As Integer = d1.Year
    Dim dt1 As New Date(y, 1, 1)
    Dim dt2 As New Date(y, 12, 31)
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton6").Checked Then
    filter1 = "1=1"
Else If e.Form.Controls("RadioButton14").Checked Then
    filter1 = "订单日期 < #" & d1 & "#"
End If

Dim c6 As String = e.Form.controls("ComboBox6").Value
If c6 <> "全部" Then
    Dim tt As Table = e.Form.Controls("Table10").Table
    If tt.Current IsNot Nothing Then
        filter1 &= " and " & c6 & " = '" & tt.Current(c6) & "'"
    End If
End If

Dim tp As DateGroupEnum = 0

Dim g As New GroupTableBuilder("临时统计表", DataTables("表A"))
g.Groups.AddDef("订单日期", tp, "日期")
g.Totals.AddDef("销售额")
g.Totals.AddDef("成本合计")
g.Totals.AddDef("利润合计")
g.Totals.AddDef("采购成本")
g.Totals.AddDef("返点成本")
g.Filter = filter1
g.Build()

'Dim t As Table = Tables("临时统计表")
't.Sort = "日期"

Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("临时统计表") '定义一个变量t引用数据表
Dim sm As Integer = 0
Chart= Forms("统计窗口").Controls("Chart1") ' 引用窗口中的图表
chart.SeriesList.Clear
chart.AxisX.ClearValueLabel
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
For Each r As Row In t.Rows
    For Each c As Col In t.Cols
        If c.name <> "日期" Then
            sm += r(c.name)
        End If
    Next
    For Each c As Col In t.Cols
        If c.name <> "日期" Then
            Series = Chart.SeriesList.Add() '增加一个图系
            Series.Length = 1 '一个系列只能包括一个值
            Series.Text = c.caption & "(" & r(c.name) & ")" '设置图系的标题
            Series.Y(0) = r(c.name) '指定值
            Series.DataLabelText = Math.Round(r(c.name)*100/sm,2) & "%" '计算百分比
        End If
    Next
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East '图列显示在东方(右方)


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/11 21:34:00 [显示全部帖子]

一样啊。看2楼。

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/11 21:52:00 [显示全部帖子]

Dim d1 As Date = e.Form.Controls("DateTimePicker5").Value
If d1 = Nothing Then d1 = Date.Today
Dim filter1 As String = ""
If e.Form.Controls("RadioButton1").Checked Then
    filter1 = "订单日期 = #" & d1 & "#"
ElseIf e.Form.Controls("RadioButton2").Checked Then
    Dim w As Integer = d1.DayOfWeek '算出今天是星期几
    Dim dt1 As Date = d1.AddDays(0 - w) '获取本周的第一天 ,星期一到星期天
    Dim dt2 As Date = d1.AddDays(6 - w) '获取本周的最后一天
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton3").Checked Then
    Dim y As Integer = d1.Year
    Dim m As Integer = d1.Month
    Dim dt1 As New Date(y, m, 1)
    Dim dt2 As New Date(y, m, Date.DaysInMonth(y, m)) '获取本月的最后一天
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton4").Checked Then
    Dim y As Integer = d1.Year
    Dim q As Integer = (d1.Month - 1) \ 3 + 1 '计算现在是第几个季度
    Dim dt1 As New Date(y, 3 * (q - 1) + 1, 1) '获取本季度的第一天
    Dim dt2 As New Date(y, 3 * q, Date.DaysInMonth(y,3 * q)) '获取本季度的最后一天
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton5").Checked Then
    Dim y As Integer = d1.Year
    Dim dt1 As New Date(y, 1, 1)
    Dim dt2 As New Date(y, 12, 31)
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton6").Checked Then
    filter1 = "1=1"
Else If e.Form.Controls("RadioButton14").Checked Then
    filter1 = "订单日期 < #" & d1 & "#"
End If

Dim Chart As WinForm.Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Dim series As winform.ChartSeries
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.ClearValueLabel
Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '图表类型改为Bar(条形)

Dim c6 As String = e.Form.controls("ComboBox6").Value
Dim g As New GroupTableBuilder("临时统计表", DataTables("表A"))
g.Groups.AddDef(c6)
g.Totals.AddDef("销售额")
g.Totals.AddDef("成本合计")
g.Totals.AddDef("利润合计")
g.Totals.AddDef("采购成本")
g.Totals.AddDef("返点成本")
g.Filter = filter1
g.Build()

Dim ls As new List(Of String)
Dim t As Table = Tables("临时统计表")
For i As Integer = 7 To 11
    Dim c As WinForm.CheckBox = e.Form.Controls("CheckBox" & i)
    If c.Checked Then
        ls.add(c.Text)
    End If
Next
For Each r As Row In t.Rows
   
    Series = Chart.SeriesList.Add() '增加一个图系
    Series.Length = ls.count
    Series.TooltipText = r(c6) & " : {#YVAL}"
    Series.Text = r(c6)
    For i As Integer = 0 To ls.Count - 1
        Series.X(i) = i
        Series.Y(i) = r(ls(i))
        Chart.AxisX.SetValueLabel(i, ls(i)) '指定字符表示
    Next
Next

Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East '图列显示在东方(右方)
Chart.AxisX.AnnoWithLabels = True '启用字符标示


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/12 9:14:00 [显示全部帖子]

没看懂你什么意思,看5楼代码自己消化一下
[此贴子已经被作者于2015/10/12 9:14:06编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/12 22:21:00 [显示全部帖子]

Dim d1 As Date = e.Form.Controls("DateTimePicker5").Value
If d1 = Nothing Then d1 = Date.Today
Dim filter1 As String = ""
If e.Form.Controls("RadioButton1").Checked Then
    filter1 = "订单日期 = #" & d1 & "#"
ElseIf e.Form.Controls("RadioButton2").Checked Then
    Dim w As Integer = d1.DayOfWeek '算出今天是星期几
    Dim dt1 As Date = d1.AddDays(0 - w) '获取本周的第一天 ,星期一到星期天
    Dim dt2 As Date = d1.AddDays(6 - w) '获取本周的最后一天
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton3").Checked Then
    Dim y As Integer = d1.Year
    Dim m As Integer = d1.Month
    Dim dt1 As New Date(y, m, 1)
    Dim dt2 As New Date(y, m, Date.DaysInMonth(y, m)) '获取本月的最后一天
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton4").Checked Then
    Dim y As Integer = d1.Year
    Dim q As Integer = (d1.Month - 1) \ 3 + 1 '计算现在是第几个季度
    Dim dt1 As New Date(y, 3 * (q - 1) + 1, 1) '获取本季度的第一天
    Dim dt2 As New Date(y, 3 * q, Date.DaysInMonth(y,3 * q)) '获取本季度的最后一天
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton5").Checked Then
    Dim y As Integer = d1.Year
    Dim dt1 As New Date(y, 1, 1)
    Dim dt2 As New Date(y, 12, 31)
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton6").Checked Then
    filter1 = "1=1"
Else If e.Form.Controls("RadioButton14").Checked Then
    filter1 = "订单日期 < #" & d1 & "#"
End If

Dim c6 As String = e.Form.controls("ComboBox6").Value
If c6 <> "全部" Then
    Dim tt As Table = e.Form.Controls("Table10").Table
    If tt.Current IsNot Nothing Then
        filter1 &= " and " & c6 & " = '" & tt.Current(c6) & "'"
    End If
End If

Dim tp As DateGroupEnum = 0

Dim g As New GroupTableBuilder("临时统计表", DataTables("表A"))
g.Groups.AddDef("订单日期", tp, "日期")
g.Totals.AddDef("销售额")
g.Totals.AddDef("成本合计")
g.Totals.AddDef("利润合计")
g.Totals.AddDef("采购成本")
g.Totals.AddDef("返点成本")
g.Filter = filter1
g.Build()

'Dim t As Table = Tables("临时统计表")
't.Sort = "日期"

Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("临时统计表") '定义一个变量t引用数据表
Dim sm As Integer = 0
Chart= Forms("统计窗口").Controls("Chart1") ' 引用窗口中的图表
chart.SeriesList.Clear
chart.AxisX.ClearValueLabel
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
For Each r As Row In t.Rows
    sm = r("销售额")
    For Each c As Col In t.Cols
        If c.name <> "日期" andalso c.name <> "销售额" Then
            Series = Chart.SeriesList.Add() '增加一个图系
            Series.Length = 1 '一个系列只能包括一个值
            Series.Text = c.caption & "(" & r(c.name) & ")" '设置图系的标题
            Series.Y(0) = r(c.name) '指定值
            Series.DataLabelText = Math.Round(r(c.name)*100/sm,2) & "%" '计算百分比
        End If
    Next
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East '图列显示在东方(右方)


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/12 22:59:00 [显示全部帖子]

Dim d1 As Date = e.Form.Controls("DateTimePicker5").Value
If d1 = Nothing Then d1 = Date.Today
Dim filter1 As String = ""
If e.Form.Controls("RadioButton1").Checked Then
    filter1 = "订单日期 = #" & d1 & "#"
ElseIf e.Form.Controls("RadioButton2").Checked Then
    Dim w As Integer = d1.DayOfWeek '算出今天是星期几
    Dim dt1 As Date = d1.AddDays(0 - w) '获取本周的第一天 ,星期一到星期天
    Dim dt2 As Date = d1.AddDays(6 - w) '获取本周的最后一天
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton3").Checked Then
    Dim y As Integer = d1.Year
    Dim m As Integer = d1.Month
    Dim dt1 As New Date(y, m, 1)
    Dim dt2 As New Date(y, m, Date.DaysInMonth(y, m)) '获取本月的最后一天
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton4").Checked Then
    Dim y As Integer = d1.Year
    Dim q As Integer = (d1.Month - 1) \ 3 + 1 '计算现在是第几个季度
    Dim dt1 As New Date(y, 3 * (q - 1) + 1, 1) '获取本季度的第一天
    Dim dt2 As New Date(y, 3 * q, Date.DaysInMonth(y,3 * q)) '获取本季度的最后一天
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton5").Checked Then
    Dim y As Integer = d1.Year
    Dim dt1 As New Date(y, 1, 1)
    Dim dt2 As New Date(y, 12, 31)
   
    filter1 = "订单日期 >= #" & dt1 & "# and 订单日期 <= #" & dt2 & "#"
Else If e.Form.Controls("RadioButton6").Checked Then
    filter1 = "1=1"
Else If e.Form.Controls("RadioButton14").Checked Then
    filter1 = "订单日期 < #" & d1 & "#"
End If

Dim c6 As String = e.Form.controls("ComboBox6").Value
If c6 <> "全部" Then
    Dim tt As Table = e.Form.Controls("Table10").Table
    If tt.Current IsNot Nothing Then
        filter1 &= " and " & c6 & " = '" & tt.Current(c6) & "'"
    End If
End If

Dim tp As DateGroupEnum = 0

Dim g As New GroupTableBuilder("临时统计表", DataTables("表A"))
g.Groups.AddDef("订单日期", tp, "日期")
g.Totals.AddDef("销售额")
g.Totals.AddDef("成本合计")
g.Totals.AddDef("利润合计")
g.Totals.AddDef("采购成本")
g.Totals.AddDef("返点成本")
g.VerticalTotal = True
g.Filter = filter1
g.Build()

'Dim t As Table = Tables("临时统计表")
't.Sort = "日期"

Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("临时统计表") '定义一个变量t引用数据表
Dim sm As Integer = 0
Chart= Forms("统计窗口").Controls("Chart1") ' 引用窗口中的图表
chart.SeriesList.Clear
chart.AxisX.ClearValueLabel
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
Dim r As Row = t.Rows(t.count-1)
sm = r("销售额")
For Each c As Col In t.Cols
    If c.name <> "日期" Then
        Series = Chart.SeriesList.Add() '增加一个图系
        Series.Length = 1 '一个系列只能包括一个值
        Series.Text = c.caption & "(" & r(c.name) & ")" '设置图系的标题
        Series.Y(0) = r(c.name) '指定值
        Series.DataLabelText = Math.Round(r(c.name)*100/sm,2) & "%" '计算百分比
    End If
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East '图列显示在东方(右方)


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/12 23:39:00 [显示全部帖子]

If c.name <> "日期" Then

 

改成

 

If c.name <> "日期" andalso c.name <> "销售额" Then


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/13 22:43:00 [显示全部帖子]

这里生成的临时表就是答案啊

 

Dim g As New GroupTableBuilder("临时统计表", DataTables("表A"))
g.Groups.AddDef("订单日期", tp, "日期")
g.Totals.AddDef("销售额")
g.Totals.AddDef("成本合计")
g.Totals.AddDef("利润合计")
g.Totals.AddDef("采购成本")
g.Totals.AddDef("返点成本")
g.VerticalTotal = True
g.Filter = filter1
g.Build()


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/13 23:11:00 [显示全部帖子]

请看懂上面全部代码。不是每次要增加功能都要别人帮你做啊。

 回到顶部
总数 19 1 2 下一页