vba 具有多个条件的嵌套 iif SSRS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15166452/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Nested iif with multiple conditions SSRS
提问by jenhil34
I need to write a formula for a SSRS report. I am not for sure about the exact syntax, but it I am thinking it should be a nested iif but with multiple criteria, checking the value of the chart and division fields. At the end of the day if chart=110300 and division=100 then "Intercompany AP - USA" or if chart=110300 and division=200 then "Intercompany AP - RUS" other wise, then just display the chartname. Something like this but actually written correctly.
我需要为 SSRS 报告编写一个公式。我不确定确切的语法,但我认为它应该是一个嵌套的 iif,但有多个条件,检查图表和除法字段的值。在一天结束时,如果 chart=110300 和 Division=100 那么“Intercompany AP - USA”或者如果 chart=110300 and Division=200 那么“Intercompany AP - RUS”,否则只显示图表名称。像这样的东西,但实际上写得正确。
iif Fields!chart.Value="110300" and Fields!division.Value="100" then
Fields!chartname.Value="Intercompany AP - USA" if Fields!chart.Value="110300"
and Fields!division.Value="200" then Fields!chartname.Value=
"Intercompany AP - RUS" else Fields!chartname.Value
I greatly appreciate any help on this!
我非常感谢这方面的任何帮助!
回答by Tom Jenkin
You pretty much solved this one yourself! To write this in T-SQL you right click the Chart Name and change its value to the following expression:
你几乎自己解决了这个问题!要在 T-SQL 中编写此内容,请右键单击图表名称并将其值更改为以下表达式:
IIF(Fields!chart.Value="110300" AND Fields!division.Value="100","Intercompany AP - USA",IIF(Fields!chart.Value="110300" AND Fields!division.Value="200","Intercompany AP - RUS","Default Chart Name")
See herefor explanation on how the IIF function works
有关IIF 函数如何工作的说明,请参见此处
From the link you can see that it takes the following format, where commas are used instead of "Then" or "Else":
从链接中您可以看到它采用以下格式,其中使用逗号代替“Then”或“Else”:
IIF ( boolean_expression, true_value, false_value )
IIF ( boolean_expression, true_value, false_value )
So to breakdown the expression:
所以分解表达式:
IIF(Fields!chart.Value="110300" AND Fields!division.Value="100",
"Intercompany AP - USA",
IIF(Fields!chart.Value="110300" AND Fields!division.Value="200",
"Intercompany AP - RUS",
"Default Chart Name"
)
)