该公式应考虑除以零。
感谢您的协助
答案 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
谢谢