简体   繁体   English

SSRS嵌套的IIF / CStr说明

[英]SSRS nested IIF/CStr explanation

Could someone let me know if the IIF statement below means output any value that starts with a 4 please? 有人可以让我知道下面的IIF语句是否意味着输出任何以4开头的值?

=IIF(LEFT(CStr(Fields!CLOCK_NUMBER.Value),1)="4",Fields!JOB_NO.Value, "") = IIF(LEFT(CStr(Fields!CLOCK_NUMBER.Value),1)=“ 4”,Fields!JOB_NO.Value,“”)

The short answer is yes. 简短的答案是肯定的。

Starting from the middle and working outwards this expression is doing the following.. 从中间开始,向外进行此表达式,以进行以下操作。

  1. Get the value of the field CLOCK_NUMBER 获取字段CLOCK_NUMBER的值
  2. Convert this to a string (the CSTR function) 将此转换为字符串(CSTR函数)
  3. Take the 1st character (LEFT function with 1 as the seconds parameter) 取第一个字符(以1为秒参数的LEFT功能)
  4. If the equals "4" return the Value that is in JOB_NO 如果等于“ 4”,则返回JOB_NO中的值
  5. Otherwise return an empty string 否则返回一个空字符串

If this is not working for some reason, try converting the job_no to a string before returning, that way you ensure you always return a string (in case JOB_NO is numeric). 如果由于某种原因该方法不起作用,请尝试在返回之前将job_no转换为字符串,以确保始终返回字符串(以防JOB_NO为数字)。 You can simply wrap the job_no in a CSTR like this CSTR(Fields!JOB_NO.Value) 您可以简单地将job_no包装在这样的CSTR(Fields!JOB_NO.Value)

Translates to..."try to" convert the field CLOCK_NUMBERS's native value to a string and take the LEFT(1) most significant digit(s) and if that value is "4" then return the JOB_NO Fields's value. 转换为...“尝试”以将CLOCK_NUMBERS's字段CLOCK_NUMBERS's本机值转换为字符串,并使用LEFT(1)的最高有效数字,如果该值为“ 4”,则返回JOB_NO字段的值。 else return empty string. 否则返回空字符串。

So, it is, if the first digit is 4 then return JOB_NO . 因此,如果第一个数字为4,则返回JOB_NO

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

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