如果项目没有日期,则不显示任何内容

Show nothing if the item doesn't have a date

我希望我的代码在没有日期的情况下不显示任何内容。

这是我的代码:

=format(IIF(Fields!Phase.Value = "Pre-Feasibility" OR Fields!Phase.Value = "Selection", Fields!PreFeasibilityCurrentTargetDate.Value, IIF(Fields!Phase.Value = "Feasibility" OR Fields!Phase.Value = "Definition", Fields!FeasibilityCurrentTargetDate.Value, IIF(Fields!Phase.Value = "Implementation", Fields!ImplementationCurrentTargetDate.Value, ""))), "dd-MMM-yy")

因为我将其格式化为 dd-MMM-yy,所以当项目没有日期时它会显示。如果它没有日期,我如何才能将其更改为不显示任何内容。

在此处查看 MSDN 表单, https://msdn.microsoft.com/en-us/library/ms157406.aspx

它清楚地提到 "If you specify an invalid format string, the formatted text is interpreted as a literal string which overrides the formatting."

所以。格式化后需要检查字符串,

IIF(output="dd-MMM-yy","",output)

将表达式的空白值更改为空

=Iif(Fields!Phase.Value="Operation","-", format(
IIF(Fields!Phase.Value = "Pre-Feasibility" OR Fields!Phase.Value = "Selection", 
   Fields!PreFeasibilityCurrentTargetDate.Value, 
   IIF(Fields!Phase.Value = "Feasibility" OR Fields!Phase.Value = "Definition", 
      Fields!FeasibilityCurrentTargetDate.Value, 
      IIF(Fields!Phase.Value = "Implementation",
        Fields!ImplementationCurrentTargetDate.Value, Nothing)))
, "dd-MMM-yy") )

我还建议您使用字段格式 属性 而不是值表达式中的格式函数。在这种情况下,即使字段值为空也能正常工作