reporting-services - SSRS Conditional formatting USING CONTAINS
问题描述
I'm new to SSRS and I am trying to apply conditional formatting to a field and I'm getting an error and I can't figure out why I'm getting it. The following is my expressions...
=IIf(Fields!Category.Value.ToString().Contains("TIA"),"GREEN",
IIf(Fields!Category.Value.ToString().Contains("IR"),"PURPLE",
IIf(Fields!Category.Value.ToString().Contains("TPA"),"PURPLE",
IIf(Fields!Category.Value.ToString().Contains("ICH"),"RED",
IIf(Fields!Category.Value.ToString().Contains("SAH"),"RED",
TRUE,"TRANSPARENT")))))
解决方案
It looks like you have mixed the syntax for IIF and SWITCH (the 'True' at the end looks typically from a SWITCH statement)
In this case SWITCH is usually easier to read..
try this
=SWITCH
(
Fields!Category.Value.ToString().Contains("TIA"), "Green",
Fields!Category.Value.ToString().Contains("IR") , "Purple",
Fields!Category.Value.ToString().Contains("TPA"), "Purple",
Fields!Category.Value.ToString().Contains("ICH"), "Red",
Fields!Category.Value.ToString().Contains("SAH"), "Red",
TRUE, Nothing
)
I used Nothing rather than transparent as that is the default for a cell background. Both should work, I just prefer Nothing
as that is internally the default for a cell background.
推荐阅读
- reactjs - 如何使用 ionic v4 添加自定义 webpack 配置并做出反应?
- c# - 无法加载文件或程序集......但不是一开始?
- python - 在 Python 或 C++ 中删除 K -Means 聚类/的背景掩码
- python - 用另一个字符替换一个字符序列
- javascript - React 和 Material UI:如何仅扩展一张卡片
- python - 原始 f 字符串 SyntaxError
- hazelcast - Hazelcast mancenter 分区组监控
- r - 在 R 中为主题建模预处理文本时得到奇怪的字符
- c# - 如何在 WPF 中取消被阻止的任务
- javascript - WebView .reload() 在 iOS 上无法正常工作