【问题标题】:disctinctcount from another dataset having multiple grouping来自具有多个分组的另一个数据集的 distinctcount
【发布时间】:2014-02-08 09:25:17
【问题描述】:

我有报告从 2 个数据集生成策略数量。

该表已链接到 dataset1。

我用了公式

CountDistinct(Fields!Policy_ID.Value)

我的问题是如何从第二个数据集“AccountingV10Dataset”中获取字段 Policy_ID 的不同计数,特别是我将 Contract_Start_Month、Contract_Cover_Type 和 Primary_LOB 分组。

下面是报告设计的屏幕截图,以帮助您了解我的要求

报告应按如下方式生成:

【问题讨论】:

    标签: reporting-services ssrs-2008


    【解决方案1】:

    我会在 Dataset 层中推导出 Distinct Count,例如在 SQL 中。 SSRS 聚合函数仅此而已。

    【讨论】:

      【解决方案2】:

      我设法以这种方式解决了:

      我创建了以下代码来计算另一个数据集的差异计数:

      Dim suma As Decimal = New Decimal()
      
      Public Function SumLookup(ByVal items As Object(),ByVal CountSum As String) As Decimal
      If items Is Nothing Then
      Return Nothing
      End If
      
      Dim ct as Integer = New Integer()
      Dim PolId as Integer = New Integer()
      suma = 0
      ct = 0
      PolId = 0
      For Each item As Object In items
      suma += Convert.ToDecimal(item)
      If (CountSum = "SUM") then
      ct += 1
      Else If (PolID <> Convert.ToInt32(item)) then 
      ct += 1
      END If
      PolId = Convert.ToInt32(item)
      Next
      If (ct = 0) Then return 0 else If(CountSum = "SUM") then return suma else return ct 
      End Function
      
      
      Public Function GetMyVal() as Decimal
      GetMyVal = suma 
      End Function
      

      我通过以下方式调用此函数:

      =code.SumLookup(Lookupset(Fields!Contract_Start_Month.Value & "-" & Fields!Contract_Cover_Type.Value & "-" & Fields!Primary_LOB.Value,Fields!Contract_Year_Start_Month.Value & "-" & Fields!Cover_Type.Value & "-" & Fields!LOB.Value,Fields!Layer_ID.Value, "AccountingV10Dataset"),"COUNT")
      

      希望我的解决方案能像对我一样对其他用户有所帮助。

      问候,

      【讨论】:

        猜你喜欢
        • 2014-07-11
        • 2022-11-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-05-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多