[英]SSRS - Group set of rows based on calculated value from the row's data
I want to group ( display ) a set of row(s) based on a calculation on one of row's column data. 我想基于对一行列数据之一的计算来对一组行进行分组(显示)。
Lets say I have 3 columns in my tablix. 可以说我Tablix中有3列。 1. Description 2. Amount 3. Debit/Credit
1.说明2.金额3.借方/贷方
based on the D/C value I would like to sum up the amount ( for debit its -ve and credit is +ve) until the total gets to zero and then group those rows into a different color or a line space between other set of rows. 根据D / C值,我想对金额进行总计(对于其借方-ve和贷方为+ ve),直到总数变为零,然后将这些行分组为不同的颜色或其他行之间的行间距行。
Example output: 输出示例:
Thanks 谢谢
Karthik 卡尔提克
I've recreated your scenario using the dataset you have provided in the question. 我已经使用问题中提供的数据集重新创建了您的方案。 I am using the Amount cell
background-color
property to group the sums. 我正在使用“数量”单元格
background-color
属性将总和分组。
This is the tablix I've created. 这是我创建的tablix。 The selected Cell background-property is set to a expression (see below):
所选单元格的背景属性设置为一个表达式(如下所示):
In Report
menu, Report Properties...
/ Code
tab put this function in the text area. 在
Report
菜单中, Report Properties...
/ Code
选项卡将此功能放在文本区域中。
Dim prevColor As String = "Red"
Dim accumulator As Double = 0
Public Function GetSumColor(ByVal value as Double) as String
Dim color As String
accumulator = accumulator + value
color = prevColor
If accumulator = 0 Then
If prevColor = "Red" Then
prevColor = "Yellow"
Else
prevColor = "Red"
End If
End If
Return color
End Function
This function will change the cell background color between Red
or Yellow
based on sums equals to zero (you can use the whatever color you want). 此功能将根据等于零的总和在
Red
或Yellow
之间更改单元格背景颜色(您可以使用所需的任何颜色)。
In the Amount cell background-color property use this expression: 在“数量”单元格background-color属性中,使用以下表达式:
=Code.GetSumColor(
IIF(Fields!D_C.Value="C",-Fields!Amount.Value,Fields!Amount.Value)
)
It will produce the following result: 它将产生以下结果:
Let me know if this helps you. 让我知道这是否对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.