Foxtable(狐表)用户栏目专家坐堂 → 求动态分组统计


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

主题:求动态分组统计

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


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

上传项目。

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


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

Dim tbs() As String = { "表1", "表2"}

Dim cs1() As String = { "指标1", "指标2"}

Dim cs2() As String = { "指标A", "指标B", "指标C"}

Dim snum As Integer = 0
Dim slen As Integer = 100
Dim scount As Integer = 10

Dim ls As new List(Of String())

ls.Add(cs1)

ls.add(cs2)

Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("列名", Gettype(String), 32)
dtb.AddDef("标题", Gettype(String), 32)
For i As Integer = 1 To scount
    dtb.AddDef("临时列" & i, Gettype(Double), "", snum+slen*(i-1) & "-" & snum+slen*i)
Next
dtb.Build()

For i As Integer = 0 To tbs.Length - 1
   
    Dim cs As String() = ls(i)
   
    For j As Integer = 0 To cs.Length - 1
       
        Dim fdr = DataTables("统计").AddNew
       
        fdr("列名") = cs(j)
       
        fdr("标题") = Tables(tbs(i)).Cols(cs(j)).Caption
       
        Dim All As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " is not null")
        For Each dc As DataCol In DataTables("统计").datacols
            If dc.Name Like "临时列*" Then
                Dim ary() As String = dc.Caption.Split("-")
                Dim c As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " >= " & ary(0) & " and " & cs(j) & " < " & ary(1) & " and " & cs(j) & " is not null")
                fdr(dc.name) = c / All *100
            End If
           
        Next
       
    Next
   
Next

MainTable = Tables("统计")


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


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

呃,要学会变通。直接赋值

 

Dim snum As Integer = Forms("窗口1").Controls("TexBox1").Text
Dim slen As Integer = 100
Dim scount As Integer = 10


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


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

请参考4楼代码,只要赋值成功,就没问题

 

Dim snum As Integer = Forms("窗口1").Controls("TexBox1").Text
Dim slen As Integer = Forms("窗口1").Controls("TexBox2").Text
Dim scount As Integer = Forms("窗口1").Controls("TexBox3").Text


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


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

 

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


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


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

Dim tbs() As String = { "表1", "表2"}
Dim cs1() As String = { "指标1", "指标2"}
Dim cs2() As String = { "指标A", "指标B", "指标C"}
Dim snum As Integer = Forms("窗口1").Controls("TextBox1").Text
Dim slen As Integer = Forms("窗口1").Controls("TextBox2").Text
Dim scount As Integer = Forms("窗口1").Controls("TextBox3").Text

Dim ls As new List(Of String())

ls.Add(cs1)

ls.add(cs2)

Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("列名", Gettype(String), 32)
dtb.AddDef("标题", Gettype(String), 32)
For i As Integer = 1 To scount
    dtb.AddDef("临时列" & i, Gettype(Double), "", snum+slen*(i-1) & "-" & snum+slen*i)
Next
dtb.Build()

For i As Integer = 0 To tbs.Length - 1
   
    Dim cs As String() = ls(i)
   
    For j As Integer = 0 To cs.Length - 1
       
        Dim fdr = DataTables("统计").AddNew
       
        fdr("列名") = cs(j)
       
        fdr("标题") = Tables(tbs(i)).Cols(cs(j)).Caption
       
        Dim All As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " is not null")
        For Each dc As DataCol In DataTables("统计").datacols
            If dc.Name Like "临时列*" Then
               
                Dim ary() As String = dc.Caption.Split("-")
                If ary.length = 2 Then
                    Dim c As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " >= " & ary(0) & " and " & cs(j) & " < " & ary(1) & " and " & cs(j) & " is not null")
                    fdr(dc.name) = c / All *100
                Else If ary.length = 3 Then
                    Dim c As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " >= " & -ary(1) & " and " & cs(j) & " < " & ary(2) & " and " & cs(j) & " is not null")
                    fdr(dc.name) = c / All *100
                Else If ary.length = 4 Then
                    Dim c As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " >= " & -ary(1) & " and " & cs(j) & " < " & -ary(3) & " and " & cs(j) & " is not null")
                    fdr(dc.name) = c / All *100
                End If
            End If
        Next
       
    Next
   
Next

MainTable = Tables("统计")


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


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

Dim tbs() As String = { "表1", "表2"}
Dim cs1() As String = { "指标1", "指标2"}
Dim cs2() As String = { "指标A", "指标B", "指标C"}
Dim snum As Double = Forms("窗口1").Controls("TextBox1").Text
Dim slen As Double = Forms("窗口1").Controls("TextBox2").Text
Dim scount As Double = Forms("窗口1").Controls("TextBox3").Text

Dim ls As new List(Of String())

ls.Add(cs1)

ls.add(cs2)

Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("列名", Gettype(String), 32)
dtb.AddDef("标题", Gettype(String), 32)
For i As Integer = 1 To scount
    dtb.AddDef("临时列" & i, Gettype(Double), "", snum+slen*(i-1) & "-" & snum+slen*i)
Next
dtb.Build()

For i As Integer = 0 To tbs.Length - 1
   
    Dim cs As String() = ls(i)
   
    For j As Integer = 0 To cs.Length - 1
       
        Dim fdr = DataTables("统计").AddNew
       
        fdr("列名") = cs(j)
       
        fdr("标题") = Tables(tbs(i)).Cols(cs(j)).Caption
       
        Dim All As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " is not null")
        For Each dc As DataCol In DataTables("统计").datacols
            If dc.Name Like "临时列*" Then
               
                Dim ary() As String = dc.Caption.Split("-")
                If ary.length = 2 Then
                    Dim c As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " >= " & ary(0) & " and " & cs(j) & " < " & ary(1) & " and " & cs(j) & " is not null")
                    fdr(dc.name) = c / All *100
                Else If ary.length = 3 Then
                    Dim c As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " >= " & -ary(1) & " and " & cs(j) & " < " & ary(2) & " and " & cs(j) & " is not null")
                    fdr(dc.name) = c / All *100
                Else If ary.length = 4 Then
                    Dim c As Double = Tables(tbs(i)).Compute("count(" & cs(j) & ")", cs(j) & " >= " & -ary(1) & " and " & cs(j) & " < " & -ary(3) & " and " & cs(j) & " is not null")
                    fdr(dc.name) = c / All *100
                End If
            End If
        Next
       
    Next
   
Next

MainTable = Tables("统计")


 回到顶部