有条件地格式化文本框

时间:2019-03-21 14:03:23

标签: vba visual-studio-2012 reporting-services reportbuilder3.0 ssrs-expression

我正在使用ReportBuilder

下面是一个表达式,用于根据单元格中的值更改背景色。我想在现有表达式中添加一个新条件,以将textbox22中的“ N / A”更改为浅绿色

=iif(isnothing(reportitems!Textbox22.value),Nothing, switch(reportitems!Textbox22.value >1 and reportitems!Textbox22.value <=50,"#fd6767",reportitems!Textbox22.value >=51 and reportitems!Textbox22.value <=79,"#f8d3a9",reportitems!Textbox22.value >=80 and reportitems!Textbox22.value <=100,"LightGreen",reportitems!Textbox22.value = 0, "#fd6767"))

这是设计视图

enter image description here

这是单元格中的表达式,如果该单元格没有值,它将带回“ N / A”。

=iif(isnothing(lookup(Fields!StatID.value,Fields!statID.value,Fields!pass_rate.value,"Res2nd")),"N/A",lookup(Fields!StatID.value,Fields!statID.value,Fields!pass_rate.value,"Res2nd"))

这是输出

enter image description here

我尝试了以下方法,但这会使所有单元格变白

 =switch(reportitems!Textbox22.value >1 and reportitems!Textbox22.value <=50,"#fd6767",reportitems!Textbox22.value >=51 and reportitems!Textbox22.value <=79,"#f8d3a9",reportitems!Textbox22.value >=80 and reportitems!Textbox22.value <=100,"LightGreen",reportitems!Textbox22.value = 0, "#fd6767",reportitems!Textbox22.value = "N/A","LightGreen")

3 个答案:

答案 0 :(得分:0)

将您的表情修改为:

=iif(isnothing(reportitems!Textbox22.value),Nothing, switch(reportitems!Textbox22.value >1 and reportitems!Textbox22.value <=50,"#fd6767",reportitems!Textbox22.value >=51 and reportitems!Textbox22.value <=79,"#f8d3a9",reportitems!Textbox22.value >=80 and reportitems!Textbox22.value <=100,"LightGreen",reportitems!Textbox22.value = 0, "#fd6767",reportitems!Textbox22.value ="N/A","LightGreen"))

答案 1 :(得分:0)

尝试以下表达式:

=switch(reportitems!Textbox22.value >=0 and reportitems!Textbox22.value <=50,"#fd6767",reportitems!Textbox22.value >=51 and reportitems!Textbox22.value <= 79,"#f8d3a9",reportitems!Textbox22.value >=80 or reportitems!Textbox22.value  = "N/A","LightGreen")

答案 2 :(得分:0)

设法通过使用以下内容最终使此工作

=iif(reportitems!Textbox22.value >=0 and reportitems!Textbox22.value <=50 ,"#f1b1b1",iif(reportitems!Textbox22.value >50 and reportitems!Textbox22.value <=79,"#f8d3a9","LightGreen"))