Foxtable(狐表)用户栏目专家坐堂 → 组合多个统计结果 问题


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

主题:组合多个统计结果 问题

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


加好友 发短信
等级:九尾狐 帖子:2355 积分:16187 威望:0 精华:0 注册:2013/9/1 8:09:00
组合多个统计结果 问题  发帖心情 Post By:2016/7/18 9:27:00 [只看该作者]

狐爸辛苦了。一大早回复这么多问题!!

昨天遇到了一个问题,研究了一个晚上没弄出来。。。


此主题相关图片如下:5.jpg
按此在新窗口浏览图片
就是为什么上图的356行之后,就只显示一个统计表的数据,没有把另一个的统计表通过 会员卡号 给组合进来 

代码如下: 

'下面的代码是搜索条件,可略过,直接看下面标黄色的 统计代码

第一个统计表的搜索条件

Dim Filter As String

With e.Form.Controls("DateTimePicker1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "开卡日期 >= '" & .Value & "'"
    End If
End With

With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "开卡日期 <= '" & .Value & "'"
    End If
End With


With e.Form.Controls("checkedComboBox5")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "门店名称 in ( '" & .text.replace(",","','") & " ') "
    End If
End With

With e.Form.Controls("checkedComboBox4")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "出生月 in ( '" & .text.replace(",","','") & " ') "
    End If
End With


With e.Form.Controls("checkedComboBox3")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "会员状态 in ( '" & .text.replace(",","','") & " ') "
    End If
End With

With e.Form.Controls("checkedComboBox1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "会员类型 in ( '" & .text.replace(",","','") & " ') "
    End If
End With


With e.Form.Controls("checkedComboBox2")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "会员系列 in ( '" & .text.replace(",","','") & " ') "
    End If
End With

With e.Form.Controls("ComboBox1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "性别 in ( '" & .text.replace(",","','") & " ') "
    End If
End With

With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "姓名 = '" & .Value & "'"
    End If
End With

With e.Form.Controls("TextBox3")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "会员卡号 = '" & .Value & "'"
    End If
End With

With e.Form.Controls("TextBox2")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "手机 = '" & .Value & "'"
    End If
End With


With e.Form.Controls("DateTimePicker3")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售日期 >= '" & .Value & "'"
    End If
End With

With e.Form.Controls("DateTimePicker4")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售日期 <= '" & .Value & "'"
    End If
End With
'第二个统计表的搜索条件
Dim filter2 As String

With e.Form.Controls("checkedComboBox5")
    If .Value IsNot Nothing Then
        If filter2 >"" Then
            filter2 = filter2 & " And "
        End If
        filter2 = filter2 & "门店 in ( '" & .text.replace(",","','") & " ') "
    End If
End With

With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If filter2 >"" Then
            filter2 = filter2 & " And "
        End If
        filter2 = filter2 & "会员姓名 = '" & .Value & "'"
    End If
End With

With e.Form.Controls("TextBox3")
    If .Value IsNot Nothing Then
        If filter2 >"" Then
            filter2 = filter2 & " And "
        End If
        filter2 = filter2 & "会员卡号 = '" & .Value & "'"
    End If
End With

With e.Form.Controls("checkedComboBox1")
    If .Value IsNot Nothing Then
        If filter2 >"" Then
            filter2 = filter2 & " And "
        End If
        filter2 = filter2 & "会员类型 in ( '" & .text.replace(",","','") & " ') "
    End If
End With

With e.Form.Controls("DateTimePicker3")
    If .Value IsNot Nothing Then
        If Filter2 >"" Then
            Filter2 = Filter2 & " And "
        End If
        Filter2 = Filter2 & "销售日期 >= '" & .Value & "'"
    End If
End With

With e.Form.Controls("DateTimePicker4")
    If .Value IsNot Nothing Then
        If Filter2 >"" Then
            Filter2 = Filter2 & " And "
        End If
        Filter2 = Filter2 & "销售日期 <= '" & .Value & "'"
    End If
End With

'=======================上面是搜索条件,下面是组合多个统计表的代码 

Dim bd1 As New SQLgroupTableBuilder("统计表1","rfm分析2")
Dim dt1 As fxDataSource
bd1.C
bd1.Groups.AddDef("发卡单位") '添加客户列用于水平分组
bd1.Groups.AddDef("门店名称") '添加客户列用于水平分组
bd1.Groups.AddDef("建档日期",DateGroupEnum.none) '添加客户列用于水平分组
bd1.Groups.AddDef("会员状态") '添加客户列用于水平分组
bd1.Groups.AddDef("会员系列") '添加客户列用于水平分组
bd1.Groups.AddDef("会员类型") '添加客户列用于水平分组
bd1.Groups.AddDef("性别") '添加客户列用于水平分组
bd1.Groups.AddDef("会员卡号") '添加客户列用于水平分组
bd1.Groups.AddDef("姓名") '添加客户列用于水平分组
bd1.Groups.AddDef("手机") '添加客户列用于水平分组
bd1.Groups.AddDef("出生日期",DateGroupEnum.none) '添加客户列用于水平分组
bd1.Groups.AddDef("当前维护人") '添加客户列用于水平分组
bd1.Totals.AddDef("销售日期",AggregateEnum.max,"末次购买时间") '添加客户列用于水平分组
bd1.Totals.AddDef("销售日期",AggregateEnum.count,"买过多少次") '添加客户列用于水平分组
bd1.Totals.AddDef("销售金额","总购买金额") '添加客户列用于水平分组
bd1.Totals.AddDef("吊牌金额","总吊牌金额") '添加客户列用于水平分组
bd1.Filter = filter   

dt1 = bd1.BuildDataSource()

 

Dim bd2 As New SQLcrossTableBuilder("统计表1","销售明细")
Dim dt2 As fxDataSource
bd2.C
'bd2.HGroups.AddDef("上级名称") '添加客户列用于水平分组
'bd2.HGroups.AddDef("门店") '添加客户列用于水平分组
bd2.HGroups.AddDef("会员姓名") '添加客户列用于水平分组
bd2.HGroups.AddDef("会员类型") '添加客户列用于水平分组
bd2.HGroups.AddDef("会员卡号") '添加客户列用于水平分组
bd2.VGroups.AddDef("品类") '添加日期列用于垂直分组,按月分组
bd2.VGroups.AddDef("大类") '添加日期列用于垂直分组,按月分组
bd2.Totals.AddDef("销售数量") '添加数量列用于统计
        If Filter2 >"" Then
            Filter2 = Filter2 & " And "
        End If
bd2.Filter = filter2 & "会员卡号 <> ''"
dt2 = bd2.BuildDataSource()

Dim nms1 As String() = {"会员卡号","姓名","会员类型"} '指定连接列
Dim nms2 As String() = {"会员卡号","会员姓名","会员类型"} '指定连接列  这是两个统计表都有的字段

dt1.Combine(nms1,dt2,nms2) '将销售统计数据组合到进货统计数据
Tables(e.Form.Name & "_table1").DataSource = dt1

 

 

[此贴子已经被作者于2016/7/18 9:29:53编辑过]

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


加好友 发短信
等级:狐神 帖子:5015 积分:25363 威望:0 精华:0 注册:2015/8/18 9:21:00
  发帖心情 Post By:2016/7/18 10:25:00 [只看该作者]

1、第二个表统计的时候也加上这些字段
2、合并后编码查询补充这些值

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


加好友 发短信
等级:九尾狐 帖子:2355 积分:16187 威望:0 精华:0 注册:2013/9/1 8:09:00
  发帖心情 Post By:2016/7/18 16:09:00 [只看该作者]

谢谢 Hyphen老师。我增加了字段。

那怎么才能 补充这些值呢?通过 会员卡号 来查找rfm分析2的值,然后补充到第二个表中呢。。。

 

Dim bd2 As New SQLcrossTableBuilder("统计表2","销售明细2")
Dim dt2 As fxDataSource
bd2.C
bd2.hGroups.AddDef("发卡单位") '添加客户列用于水平分组
bd2.hGroups.AddDef("门店名称") '添加客户列用于水平分组
bd2.hGroups.AddDef("建档日期",DateGroupEnum.none) '添加客户列用于水平分组
bd2.hGroups.AddDef("会员状态") '添加客户列用于水平分组
bd2.hGroups.AddDef("会员系列") '添加客户列用于水平分组
bd2.hGroups.AddDef("会员类型") '添加客户列用于水平分组
bd2.hGroups.AddDef("性别") '添加客户列用于水平分组
bd2.HGroups.AddDef("姓名") '添加客户列用于水平分组
bd2.HGroups.AddDef("会员卡号") '添加客户列用于水平分组
bd2.hGroups.AddDef("手机") '添加客户列用于水平分组
bd2.hGroups.AddDef("出生日期",DateGroupEnum.none) '添加客户列用于水平分组
bd2.hGroups.AddDef("当前维护人") '添加客户列用于水平分组
bd2.VGroups.AddDef("品类") '添加日期列用于垂直分组,按月分组
bd2.VGroups.AddDef("大类") '添加日期列用于垂直分组,按月分组
bd2.Totals.AddDef("销售数量") '添加数量列用于统计
        If Filter2 >"" Then
            Filter2 = Filter2 & " And "
        End If
bd2.Filter = filter2 & "会员卡号 <> ''"
dt2 = bd2.BuildDataSource()

Dim nms1 As String() = {"会员卡号","姓名","会员类型","发卡单位","门店名称","建档日期","会员状态","会员系列","性别","手机","出生日期","当前维护人"} '指定连接列
Dim nms2 As String() = {"会员卡号","姓名","会员类型","发卡单位","门店名称","建档日期","会员状态","会员系列","性别","手机","出生日期","当前维护人"} '指定连接列


dt1.Combine(nms1,dt2,nms2) '将销售统计数据组合到进货统计数据
Tables(e.Form.Name & "_table1").DataSource = dt1


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


加好友 发短信
等级:狐神 帖子:5015 积分:25363 威望:0 精华:0 注册:2015/8/18 9:21:00
  发帖心情 Post By:2016/7/18 16:54:00 [只看该作者]


 回到顶部