简体   繁体   English

SQL SSRS将条件添加到ssrs表达式中

[英]SQL SSRS add if condition into ssrs expression

I am creating a simple report in SSRS One of the fields is an address, which has this expression value 我正在SSRS中创建一个简单的报告,其中一个字段是地址,该地址具有此表达式值

=First(Fields!BILL_CITY.Value) & ", " & Fields!BILL_PROV.Value & " " & Fields!BILL_ZIP.Value

What I want to do, is within that expression within SSRS, I want to add a condition. 我想做的是在SSRS中的该表达式内,我想添加一个条件。

If the Fields!BILL_ZIP.Value is only 5 digits, do nothing. 如果Fields!BILL_ZIP.Value只有5位数字,则什么也不做。 If the value is more than 5 digits, add a dash after the fifth digit. 如果该值超过5位数字,请在第五位数字后添加一个破折号。

So if customer sends the shorthand version of the zipcode it will appear as 45040 but if he sends the long version, it will be 45040-8999 因此,如果客户发送邮政编码的简写版本,它将显示为45040,但是如果他发送长版本,则它将显示为45040-8999

Does anybody know how to do this? 有人知道怎么做这个吗? Creating the condition probably wouldn't be too hard, but how do I put it within the SSRS expression format? 创建条件可能不会太难,但是如何将其置于SSRS表达式格式之内?

尝试:

= IIF(LENGTH(Fields!BILL_ZIP.Value) = 5, Fields!BILL_ZIP.Value & "-", Fields!BILL_ZIP.Value)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM