SSRS 自定义合计
SSRS Custom Total
我有一系列 table,它们基于 SSRS 中的帐户组和帐户代码数据集。
我正在使用一些自定义代码 return 将来自其他两个数据集的值相加,以便并排比较。我正在 return 计算个人账户和账户组的正确值,但无法正确获得每个 table 的总计。每个 table 都被过滤为仅显示特定的帐户组,因此数据集的总和不是每个 table 的总和。我确信这很简单,但它让我望而却步。
我使用的自定义代码是:
编辑 - 得到第一个 tablix 的小计,但现在这个问题:
我不得不稍微调整一下,但还是成功了。基本上必须为小计和 return 我的总计创建一个单独的 SumLookup 函数。但是,我需要 "reset" 报告中每个 tablix 的变量。目前,它只是聚合每个小计,而不仅仅是当前 tablix 中的小计。我原以为添加这样的一行会起作用,但不是,想法?函数 GetTotal() return grandTotal grandTotal = 0 End Function
已解决代码
Dim grandTotal as New Decimal()
Function SumLookup(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim suma As Decimal = New Decimal()
Dim ct as Integer = New Integer()
suma = 0
ct = 0
For Each item As Object In items
suma += Convert.ToDecimal(item)
ct += 1
Next
If (ct = 0) Then return 0 else return suma
End Function
Function SumLookups(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim sumas As Decimal = New Decimal()
Dim cts as Integer = New Integer()
sumas = 0
cts = 0
For Each item As Object In items
sumas += Convert.ToDecimal(item)
cts += 1
Next
grandTotal = grandTotal + sumas
If (cts = 0) Then return 0 else return sumas
End Function
Function GetTotal()
return grandTotal
End Function
Function GetTotalReset()
grandTotal = nothing
End Function
您没有得到总数,因为 suma
变量在每次调用 SumLookup()
函数时都会被重置。我不知道您是否正在调用 table 的每一行中的函数(即使是那些被过滤掉的函数),这会导致总数不正确。因此,如果这不是您的情况,您可以在 SumLookup
函数的范围之外创建一个变量,然后 return 来自另一个自定义函数的变量。
Dim grandTotal As Integer;
Function SumLookup(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim suma As Decimal = New Decimal()
Dim ct as Integer = New Integer()
suma = 0
ct = 0
For Each item As Object In items
suma += Convert.ToDecimal(item)
ct += 1
Next
grandTotal = grandTotal + suma
If (ct = 0) Then return 0 else return suma
End Function
Function GetTotal()
return grandTotal
End Function
另一种方法是从数据集中过滤数据,只留下计算正确总数所需的数据。
如果有帮助请告诉我。
我有一系列 table,它们基于 SSRS 中的帐户组和帐户代码数据集。
我正在使用一些自定义代码 return 将来自其他两个数据集的值相加,以便并排比较。我正在 return 计算个人账户和账户组的正确值,但无法正确获得每个 table 的总计。每个 table 都被过滤为仅显示特定的帐户组,因此数据集的总和不是每个 table 的总和。我确信这很简单,但它让我望而却步。
我使用的自定义代码是:
编辑 - 得到第一个 tablix 的小计,但现在这个问题:
我不得不稍微调整一下,但还是成功了。基本上必须为小计和 return 我的总计创建一个单独的 SumLookup 函数。但是,我需要 "reset" 报告中每个 tablix 的变量。目前,它只是聚合每个小计,而不仅仅是当前 tablix 中的小计。我原以为添加这样的一行会起作用,但不是,想法?函数 GetTotal() return grandTotal grandTotal = 0 End Function
已解决代码
Dim grandTotal as New Decimal()
Function SumLookup(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim suma As Decimal = New Decimal()
Dim ct as Integer = New Integer()
suma = 0
ct = 0
For Each item As Object In items
suma += Convert.ToDecimal(item)
ct += 1
Next
If (ct = 0) Then return 0 else return suma
End Function
Function SumLookups(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim sumas As Decimal = New Decimal()
Dim cts as Integer = New Integer()
sumas = 0
cts = 0
For Each item As Object In items
sumas += Convert.ToDecimal(item)
cts += 1
Next
grandTotal = grandTotal + sumas
If (cts = 0) Then return 0 else return sumas
End Function
Function GetTotal()
return grandTotal
End Function
Function GetTotalReset()
grandTotal = nothing
End Function
您没有得到总数,因为 suma
变量在每次调用 SumLookup()
函数时都会被重置。我不知道您是否正在调用 table 的每一行中的函数(即使是那些被过滤掉的函数),这会导致总数不正确。因此,如果这不是您的情况,您可以在 SumLookup
函数的范围之外创建一个变量,然后 return 来自另一个自定义函数的变量。
Dim grandTotal As Integer;
Function SumLookup(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim suma As Decimal = New Decimal()
Dim ct as Integer = New Integer()
suma = 0
ct = 0
For Each item As Object In items
suma += Convert.ToDecimal(item)
ct += 1
Next
grandTotal = grandTotal + suma
If (ct = 0) Then return 0 else return suma
End Function
Function GetTotal()
return grandTotal
End Function
另一种方法是从数据集中过滤数据,只留下计算正确总数所需的数据。
如果有帮助请告诉我。