Select Case e.DataCol.Name
Case "最后购买日期"
If e.DataRow.IsNull("最后购买日期") Then
e.DataRow("近度") = Nothing
Else
Dim y,m,d As Integer
Dim dt1 As Date = e.DataRow("最后购买日期")
Dim dt2 As Date = Date.Today
DateYMD(dt1,dt2,y,m,d)
e.DataRow("近度") = y * 12 + m
End If
Case "密度"
If e.DataRow.IsNull("密度") = False AndAlso e.DataRow("密度") >= 0 Then
Select Case e.DataRow("密度")
Case 0 To 2
e.DataRow("密度级别") = 1
Case 3 To 5
e.DataRow("密度级别") = 2
Case Else
e.DataRow("密度级别") = 3
End Select
End If
Case "姓名"
Dim Filter As String = "[姓名] = '" & e.NewValue & "'"
If e.DataRow.Isnull("姓名") = False
Dim pl As String = DataTables("原始数据").GetComboListString("日期", filter & " and 日期 not is null")
e.DataRow("密度") = pl.Length - pl.Replace("|","").Length +1
Else
e.DataRow("密度") = Nothing
End If
If e.DataRow.Isnull("姓名") = False
Dim pl As String = DataTables("原始数据").GetComboListString("品类", filter & " and 品类 not is null")
e.DataRow("宽度") = pl.Length - pl.Replace("|","").Length +1
Else
e.DataRow("宽度") = Nothing
End If
e.DataRow("最后购买日期") = DataTables("原始数据").Compute("Max(日期)", Filter)
Dim count As Integer = DataTables("原始数据").GetUniqueValues(Filter, "日期").count
Dim sum As Double = DataTables("原始数据").Compute("sum(金额)", Filter)
e.DataRow("平均每次购买金额") = sum / count
End Select