如何在SSRS中添加百分比列

时间:2018-06-28 14:44:38

标签: matrix reporting-services ssrs-2008 reporting ssrs-2012

我在报表生成器中有一个矩阵,可以为每个员工生成每个Fiscal_year的实际余额,其中financial_year是列组。 我需要添加一个字段来计算参数中选择的年份之间的同比百分比 例如,如果我在参数Fiscal_year 2018、2017中选择,则除了2018年实际余额和2017年实际余额之外,我还应具有YOY%=(2018 AB -2017 AB)/ 2017 AB

该公式应考虑除以零。

感谢您的协助

enter image description here enter image description here

3 个答案:

答案 0 :(得分:0)

您必须在SQL查询中创建此列,本周早些时候我遇到了同样的问题。

使用以下命令在SQL中创建查询:

With Year2017AB as ( select column names, cast(actual_bal as float) as Balance7 from data where fiscal_year = '2017') , Year2018AB as ( select column names, cast(actual_bal as float) as Balance8 from data where fiscal_year = '2018') select name column, Balance7, Balance8, (Balance8-Balance7)/Balance7 as YOY% from data d left join Year Year2017AB s on d.name = s.name left join Year2018AB e on d.name = e.name

请确保将值强制转换为浮点型,以便读取实际答案。在SSRS中将其格式化为百分比

答案 1 :(得分:0)

您的公式应该类似于

           =CStr(IIF(Parameter!<paramname>.Value ="2018, 2017", IIF(SUM(Fields!2017AB.Value > 0 ,SUM(Fields!2017AB.Value -Fields!2017AB.Value)/SUM(Fields!2017AB.Value),0)) & "%"

如果没有分组显示AB值的行,请不要使用sum。

答案 2 :(得分:0)

我使用以下公式求解,也考虑了除以零:

=IIF(SUM(iif(Fields!FISCAL_YEAR.Value = 2017,cdbl(Fields!actual_BAL.Value),0.00))=0,0,(SUM(iif(Fields!FISCAL_YEAR.Value = 2018,cdbl(Fields!actual_BAL.Value),0.00))-SUM(iif(Fields!FISCAL_YEAR.Value = 2017,cdbl(Fields!actual_BAL.Value),0.00)))/IIF(SUM(iif(Fields!FISCAL_YEAR.Value = 2017,cdbl(Fields!actual_BAL.Value),0.00))=0,1,SUM(iif(Fields!FISCAL_YEAR.Value = 2017,cdbl(Fields!actual_BAL.Value),0.00))))*100

谢谢