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

Calculate percentage in conditional formatting expression in SSRS

我有一个条件

**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,"")

谁能帮我解决这个问题。

试试这样的东西:

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

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

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

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

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

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