SSRS 将行百分比添加到 Tablix
SSRS Add Row Percentage to Tablix
我正在尝试将某种计算项(Excel 等效项)添加到我从数据集创建的 tablix 中。
例如
Type Today Month Annual
Sales 1,000 15,000 35,000
GP 200 1,500 5,000
我想在下面添加一行来计算利润百分比并且也是动态的,所以当数字发生变化时,利润百分比也会发生变化
例如
Type Today Month Annual
Sales 1,000 15,000 35,000
GP 200 1,500 5,000
Margin % 20% 10% 14.3%
如果这是在页脚中,那么您可以在字段 Type
上有条件地求和,例如 Today
列:
=SUM(IIF(Fields!Type.Value = "GP", Fields!Today.Value, Nothing)) / SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, Nothing))
当然,如果 Sales 可以为零,那么您将得到被零除的错误,因此您需要使 IIF
函数参数的 bypass the error-generating divide-by-zero calculation 的表达式更复杂一些:
=IIF(SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, 0.0)) <> 0.0,
SUM(IIF(Fields!Type.Value = "GP", Fields!Today.Value, Nothing)) / IIF(SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, 0.0)) = 0.0, 1.0, SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, Nothing))),
Nothing)
我正在尝试将某种计算项(Excel 等效项)添加到我从数据集创建的 tablix 中。
例如
Type Today Month Annual
Sales 1,000 15,000 35,000
GP 200 1,500 5,000
我想在下面添加一行来计算利润百分比并且也是动态的,所以当数字发生变化时,利润百分比也会发生变化
例如
Type Today Month Annual
Sales 1,000 15,000 35,000
GP 200 1,500 5,000
Margin % 20% 10% 14.3%
如果这是在页脚中,那么您可以在字段 Type
上有条件地求和,例如 Today
列:
=SUM(IIF(Fields!Type.Value = "GP", Fields!Today.Value, Nothing)) / SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, Nothing))
当然,如果 Sales 可以为零,那么您将得到被零除的错误,因此您需要使 IIF
函数参数的 bypass the error-generating divide-by-zero calculation 的表达式更复杂一些:
=IIF(SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, 0.0)) <> 0.0,
SUM(IIF(Fields!Type.Value = "GP", Fields!Today.Value, Nothing)) / IIF(SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, 0.0)) = 0.0, 1.0, SUM(IIF(Fields!Type.Value = "Sales", Fields!Today.Value, Nothing))),
Nothing)