问题描述
我想基于多个IFF条件在MS SSR中显示记录.任何的想法?请帮帮我!
I want to display records in MS SSRs based on multiple IFFs Condition. Any idea? Please help me!
我的表是客户",列是"cust1","cust2","cust3","cust4"
My table is "customers" and columns are "cust1", "cust2", "cust3", "cust4"
if(cust1.value!=null)
{
display cust1;
if(cust2.value!=null)
{
display cust1+","+cust2;
}
if(cust3.value!=null)
{
diplay cust1+","+cust2+"and+"+cust3
}
if(cust4.value!=null)
{
diplay cust1+","+cust2+","+cust3+"and"+cust4;
}
}else
diplay cust1;
我只是写了C#语法来理解逻辑.我想显示像结果例如:我尝试过SSRS
I just wrote C# syntax for understand logic. I want to display like resultEx: for SSRS I tried
=First(Fields!cust1.value,"customername")&
IIF(First(Fields!Cust2.value,"customername")+" ">" ",
IIF(First(Fields!Cust3.value,"customername")+" ">" ",
IIF(First(Fields!cust4.value,"customername")+" ">" ",
", "+First(Fields!Cust4.Value,"customername")+
", "+First(Fields!Cust3.Value,"customername")+
", "+First(Fields!Cust2.Value,"customername"),
" and"+First(Fields!cust1.Value,"customername"))," ")," ")
但不知道如何实现"cust2","cust3".有帮助吗?
but no idea how to implement "cust2", "cust3". Any help?
推荐答案
这是IIF表达式的工作方式.
This is how the IIF expression works.
- CND =已检查的条件:
在您的示例中:Len(First(Fields!cust1.value,"customername")) > 0
(或IsNothing(First(Fields!cust1.value,"customername"))
,但是您需要将其转过来) - DWT = true 时显示/显示的内容.因此,当条件满足时.
在您的示例中,您希望显示该值. - DWF = false 时的操作/显示.熟悉if块的"else"部分.
在您的示例中,您不希望显示任何内容或显示空字符串. - CND = The condition that is checked:
In your example:Len(First(Fields!cust1.value,"customername")) > 0
(orIsNothing(First(Fields!cust1.value,"customername"))
but then you need to turn it around) - DWT = What to do/display when true. So when the condition is met.
In your example you wish to display the value. - DWF = What to do/display when false. Familiar to the "else" part of an if-block.
In your example you wish to display nothing or an empty string.
如果您实际上想嵌套多个IIF表达式,则可以通过将 DWT 或 DWF (或两者)替换为另一个IIF来实现表达.可以根据需要嵌套多次.这是一个简单的示例:
If you actually want to nest multiple IIF expressions it is possible by just replacing a DWT or DWF (or both) with another IIF expression. This can be nested as many times as you desire. Here is a simple example:
但是,当应用于您的示例时,我认为没有必要嵌套.以下表达式将为您提供所需的结果:
However, when applied on your example I don't believe it is necessary to nest. The following expression should give you the desired result:
=IIF(Len(First(Fields!cust1.value,"customername")) > 0, First(Fields!cust1.value,"customername") + " ", "") +
IIF(Len(First(Fields!cust2.value,"customername")) > 0, First(Fields!cust2.value,"customername") + " ", "") +
IIF(Len(First(Fields!cust3.value,"customername")) > 0, First(Fields!cust3.value,"customername") + " ", "") +
IIF(Len(First(Fields!cust4.value,"customername")) > 0, First(Fields!cust4.value,"customername"), "")
这篇关于如何在SSRS报表的表达式中使用多个IIF条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!