在SSRS中计算条件格式表达式中的百分比

时间:2018-09-06 06:48:37

标签: reporting-services ssrs-2012

我有病

**If charges of any week is zero then that cell has to be highlighted in red

o If  charges of any week is 80% to 90% of total average then cell has to be highlighted in
lime

o If  charges of any week is less than 79% of total average then it cell has to be highlighted
in light orange**

我尝试了以下条件:

IIF((SUM(Fields!ChargeAmount.Value)<>0),"Red","White",iif(sum(Fields!ChargeAmount.Value>=80% and sum(Fields!ChargeAmount.Value<=90% ,Fields!ChargeAmount.Value,"")

有人可以帮我吗?

2 个答案:

答案 0 :(得分:1)

尝试类似的东西:

IIF((SUM(Fields!ChargeAmount.Value) = 0), "Red",
    IIF(SUM(Fields!ChargeAmount.Value) >= 80 and SUM(Fields!ChargeAmount.Value) <= 90, "Lime", "Orange")))

答案 1 :(得分:1)

假设您的数据集名为“ WeeklyCharges”,而您用于按周分组的字段名为“ FirstOfWeek”,请尝试以下操作:

在组(FirstOfWeek)的属性中,使用表达式

定义变量FractionOfTotalAverage
=Sum(Fields!ChargeAmount.Value)
  / (Sum(Fields!ChargeAmount.Value, "WeeklyCharges")
    / CountDistinct(Fields!FirstOfWeek.Value, "WeeklyCharges"))

对于您的每周费用TextBox的 BackgroundColor 属性,请使用如下表达式:

=Switch(
  Variables!FractionOfTotalAverage.Value < 0.5, "Red",
  Variables!FractionOfTotalAverage.Value < 0.8, "Yellow",
  Variables!FractionOfTotalAverage.Value < 0.9, "Lime")