有人可以告诉我我在SSRS中的这个公式中缺少什么吗?或者更好的是,有人可以用NESTED IIF语法编写这个相同的东西吗?需要正确嵌套的IIF或SWITCH语句语法
Switch(
(Parameters!StartMonth.Value <= 1 And Parameters!EndMonth.Value >= 1),
(Code.CalculateFraction(
(Fields!retail1.Value -Fields!cost1.Value) , Fields!cost1.Value
) *100
),
(Parameters!StartMonth.Value <= 2 And Parameters!EndMonth.Value >= 2),
(Code.CalculateFraction(
(
(Fields!retail1.Value +Fields!retail2.Value)-
(Fields!cost1.Value + Fields!cost2.Value)
) ,
(Fields!cost1.Value + Fields!cost2.Value)
) *100
)
)
这真是让我发疯。为了简单起见,我在这里只做了2次迭代。我有12个这样的下一步,我必须总结零售1直到零售12和成本1直到成本12。
我无法为这两个人摆正。
编辑:
我现在想这一点,仍然返回的第一个条件
=iif(
Parameters!StartMonth.Value <= 1 AND Parameters!EndMonth.Value >= 1,
ReportItems!txtTotal2.Value,
iif(
Parameters!StartMonth.Value <= 2 AND Parameters!EndMonth.Value >= 2,
ReportItems!txtTotal3.Value,
iif(
Parameters!StartMonth.Value <= 3 AND Parameters!EndMonth.Value >= 3,
ReportItems!txtTotal4.Value,
Nothing
)
)
)
EDIT 2的值:
想通了什么不正确。
我的整个逻辑是不正确的,以达到我期待的结果。在我的例子中很明显,无论我使用什么,无论是IIF还是只切换第一条语句,因为它是真的。
但我不得不改变逻辑来得到我想要的结果。
iif(
Parameters!EndMonth.Value = 1,
ReportItems!txtTotal1.Value,
Parameters!EndMonth.Value = 2,
ReportItems!txtTotal2.Value,
and so on
)
这解决了我的问题。谢谢你们,我很欣赏它。
你得到一个错误,或者只是不正确的结果? – 2012-03-29 14:17:59